[KPhotoAlbum] Multiple versions of an image

Aleksi Halkola halkola at gmail.com
Fri Dec 10 22:23:56 GMT 2010


Hello again!

I now got the solution I was looking for. The problem with my previous 
regexp was that I had not considered that the filename consists also of 
the folder the image is in. With the these regexps all the versions are 
correctly found.

"File versions search regexp:"
(.*)/(.{8})(.*)
"Original file replacement text:"
\1/\2.nef

The (.*)/ puts the folder into \1/, the (.{8}) takes the next 8 
characters (the basename of the original) and puts them into \2, the 
(.*) discards all the rest (which I could get with \3). The original 
name can then be reconstructed using \1/\2.nef.

I always wanted learn regular expressions but never really had any use 
for them. Now I finally got the chance :).

Cheers,

Aleksi


09.12.2010 23:23, Aleksi Halkola kirjoitti:
>
> Hello Andreas,
>
> thanks for your reply. It gave me lots of new ideas :). One that works
> with sed is:
> echo dsc_8084.jpg | sed 's/\(........\).*/\1.nef/g' -> dsc_8084.nef
> echo dsc_8084_v2.jpg | sed 's/\(........\).*/\1.nef/g' -> dsc_8084.nef
> echo dsc_8084_v2.nef | sed 's/\(........\).*/\1.nef/g' -> dsc_8084.nef
>
> i.e.
> "File versions search regexp:"
> (........).*
> "Original file replacement text:"
> \1.nef
>
> This doesn't group the photos in kphotoalbum for some reason. My ideas
> was that since most of my photos (and all from digital cameras?) have
> 8.3 letter file names the (........) matches the base of the name so
> that I can reconstruct the original with \1.nef and the .* just removes
> the rest of the versioned file name (either .jpg or _v?.jpg).
>
> Anyways, the solution I found yesterday works for most cases so I'm not
> too bothered.
>
> Cheers,
>
> Aleksi
>
>
> 08.12.2010 23:59, Andreas Neustifter kirjoitti:
>> Hi Aleksi!
>>
>> On 8 December 2010 23:09, Aleksi Halkola<halkola at gmail.com> wrote:
>>>
>>> I found a solution that I think will work pretty well for me. I took
>>> inspiration from http://www.hardakers.net/kphotoalbum/#sec-4.2,
>>>
>>> I used the following settings:
>>> "File versions search regexp:"
>>> (.*)_v[0-9]*\.(.*)
>>> "Original file replacement text:"
>>> \1.nef
>>> [...]
>>> I learned
>>> regular expressions only this evening so if anybody knows how I can
>>> catch
>>> both dsc_8237.jpg dsc_8237_v2.jpg as versions of dsc_8237.nef I'd be
>>> very
>>> happy.
>>
>> Those regular expression do not need to match the whole file, mine for
>> example are "_v[0-9]*\." and "." (a single dot). This way one can
>> insert a version between the file name and the extension and this file
>> is then recognised as new version of an old file.
>> (This is a little fiddly, it assumes that the filename has only one
>> dot in it, which is the case with my files.)
>>
>> I was not aware of the regular expression supporting named groups, so
>> in this case maybe "(.*)_v[0-9]*\.(.*)" and "\1.\2" would work? (The
>> two "(.*)" each form a group of characters that can be accessed in the
>> second expression as \1 and \2. At least it seems that this is
>> possible from your example.)
>>
>> Hope that helps,
>>
>> Andi
>> _______________________________________________
>> KPhotoAlbum mailing list
>> KPhotoAlbum at mail.kdab.com
>> http://mail.kdab.com/mailman/listinfo/kphotoalbum



More information about the Kphotoalbum mailing list