Output filename based on date

Started by andrewj, December 21, 2010, 02:32:45 AM

Previous topic - Next topic

andrewj

Hi,
I need to create output XML files where the filename is based on the image date, not the original image filename. I've tried things like the following but without success:

exiftool .......... -w output/%Y.xml *
exiftool .......... -w output/{$datetimeoriginal}.xml *

Is there any way to either:
1. Set the output filenames based on date, as above
2. Rename the output files (not the image files) using exiftool

Thanks
Andrew

Phil Harvey

Hi Andrew,

This must be done in 2 steps:

1) exiftool -X -w xml DIR

2) exiftool -ext xml -d %Y%m%d%H%M%S.xml "-filename<datetimeoriginal" DIR

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

Phil Harvey

Ooops.  I just realized that this won't work because the -d option doesn't work for XML tags (since they are not pre-defined).  Darn.

There are a few work-arounds.  One is to format the date before writing the XML:

1) exiftool -X -d %Y%m%d%H%M%S -w xml DIR

2) exiftool -ext xml "-filename<$datetimeoriginal.xml" DIR

Another is to set the filemodify date, then use that:

1) exiftool -X -w xml DIR

2) exiftool -ext xml "-filemodifydate<datetimeoriginal" DIR

3) exiftool -ext xml -d %Y%m%d%H%M%S.xml "-filename<filemodifydate" DIR

There are other alternatives too, but due to the XML limitation one must be more creative than usual.

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

andrewj

Many thanks, Phil. First option works well, and can be combined on one line using -execute.

Andrew

andrewj

Hi Phil,

We have an odd problem with this code, trying to use it cross-platform, which hopefully you can resolve.

The rename comand is effectively:

exiftool -ext xml "-filename<$datetimeoriginal.xml" "/Users/a/Library/Application Support/Bibble 5/CAQuest cache"

On Windows (with the right directory name) this works fine. On Mac or Linux we just get errors like "Warning: No writable tags found - /Users/a/Library/Application Support/Bibble 5/CAQuest cache/D3-1-5960ab.xml".

I thought it might be a case-sensitivity problem, and I've also tried the following, but with the same results:

exiftool -ext xml "-filename<$DateTimeOriginal.xml" "/Users/a/Library/Application Support/Bibble 5/CAQuest cache"

Any ideas?
Thanks,
Andrew

Phil Harvey

Hi Andrew,

I mention this every time I give a sample command:  You need single quotes around a $ symbol if you are on Mac or Linux, as opposed to double quotes on Windows.

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

andrewj