ExifTool Forum

ExifTool => Archives => Topic started by: Archive on May 12, 2010, 08:54:37 AM

Title: Adding exposuretime to filenames - prevent new directories from being created?
Post by: Archive on May 12, 2010, 08:54:37 AM
[Originally posted by struggling on 2009-06-26 19:58:16-07]


I'm putting together a batch file in Windows to rename bunches of files for me.   The final format intended is:

05pm-03m-24s F4.5 at 1_1244th sec (1090-301).jpg

The command I'm using is:

exiftool -k -d "%%I%%p-%%Mmin-%%Ssec" "-FileName<%%f_${CreateDate} F${FNumber} at HuhHuhth sec (${FileNumber}).%%e" *.jpg

The problem I'm having is indicated by the HuhHuh.  If I put in ${ExposureTime} then new directories get created.  I presume this is because there are / in the "ExposureTime" tag and the / is telling exiftool to create a new directory.   If this is indeed the problem, how can I avoid this.  Also, because Windows doesn't like "/" in filenames, how can I change the "/" to an underscore?

Thanks
Title: Re: Adding exposuretime to filenames - prevent new directories ...
Post by: Archive on May 12, 2010, 08:54:37 AM
[Originally posted by exiftool on 2009-06-26 21:02:20-07]

You can do this with a user-defined Composite tag.  The following
config file defines a MyExposureTime tag to convert the slash to
an underline:

Code:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyExposureTime => {
            Require => 'ExposureTime',
            ValueConv => '$prt[0] =~ s{/}{_}; $prt[0]',
        },
    },
);
1; # end

See the config file documentation for details about how to activate
the config file.

- Phil
Title: Re: Adding exposuretime to filenames - prevent new directories ...
Post by: Archive on May 12, 2010, 08:54:37 AM
[Originally posted by struggling on 2009-06-27 00:07:25-07]

You're the best, Phil.

I've tried to figure out as much of this stuff as possible before asking any questions, but I wasn't even on the right track with this one.   That little composite-tag did the trick.   Exiftool is truly awesome and so are you.

Thanks again