News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

String manipulation while renaming?

Started by Archive, May 12, 2010, 08:54:31 AM

Previous topic - Next topic

Archive

[Originally posted by raterus on 2009-02-20 02:59:54-08]

Hi,

I'm experimenting with ExifTool to rename my jpeg files straight out of my camera.  I using the format yymmxxxx.jpg where

yy is the current year
mm is the current month
xxxx is the last four digits of the shutter count of the camera (found in an exif tag 'shuttercount')

The problem I'm running into is the shutter count on my images now is currently 5 digits long, so I need to remove the first digit.  Alternatively, if the shutter count was low, I'd want to add some 0's to the beginning.  

Can exiftool handle this type of manipulation, or should I run another program to do this type of correction.

Thanks!
--Michael

Archive

[Originally posted by exiftool on 2009-02-20 11:32:27-08]

Hi Michael,

You can do this with a user-defined tag created with a config
file something like this:

Code:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyShutterCount => {
            Require => 'ShutterCount',
            ValueConv => 'substr("0000$val", -4)',
        },
    },
);
1; #end

And this command line:

Code:
exiftool -d %y%m "-filename<$dateTimeOriginal$myShutterCount.jpg" -ext jpg DIR

where DIR is the name of the directory containing the images.
Note: Use single quotes in the command line instead of double quotes
if you are running on a Mac or Linux.

See the config
file documentation
for instructions on how to install the config file.

- Phil

Archive

[Originally posted by raterus on 2009-02-20 14:49:39-08]

I must say 'Wow', this tool is awesome.  That worked great too, by the way.  Thanks for the suggestion, and thanks for creating such a great tool for working with images!  I think I have one more question I'm going to ask about in another question, I've searched the docs and can't find anything remotely similar.

Thanks!
--Michael