Altering the date format

Started by StarGeek, April 24, 2012, 12:06:22 AM

Previous topic - Next topic

StarGeek


I'm pre-filling some photos with some generic captions ("(person) at (place) on (date)" type thing) and I like that I can preset the date properly using the date format option.   Currently, I'm using "%B %d, %Y" to get output like "January 16, 2011".  My only problem is when the number of the day is less than 10, it returns a zero padding on the left of the day.  For example, I get "January 06, 2011" instead of my preferred "January 6, 2011".  I could remove it with my own user defined tag if I could get the variable in the proper format to begin with.   Unfortunately, I don't know enough to pull this off.  Any tips on how to get my desired formatting so I can operate on it in a user defined tag, or possibly an even better way to do it?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Alan Clifford


StarGeek

Yep tried that.  By itself, it just returns "%e" back.  Replaced in my original format, I get "January , 2011" with no date at all.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

This user-defined tag will do it, along with the -d "%B %d, %Y" formatting:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyDate => {
            Require => 'DateTimeOriginal',
            ValueConv => '$val=$prt[0]; $val=~s/\b0//; $val',
        },
);
# end



- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).