saving text documents with capture date in filename

Started by Jensen, November 11, 2010, 03:46:45 AM

Previous topic - Next topic

Jensen

I think that this may not be possible...
I have a directory of images that I want to recursively process (-r) and make text documents (all in a single folder) for each original file in the format "InputFileName_CaptureDate_Time.txt"

"546RY.psd"  would make a file named "546RY_20101011_145752.txt"



Phil Harvey

You're right, I don't think this is possible.

You can set the image file name from any metadata in the file, but you can't currently set the output text file name for extracted metadata from the metadata itself.

This is an interesting idea that I don't recall anyone ever requesting before.

With some scripting this could be do-able, but as it stands the exiftool script won't do it.

- 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 ($).

Phil Harvey

#2
Wait.  I just thought of a tricky way to achieve this:

exiftool -ext psd -w txt -execute -ext txt -tagsfromfile %d%f.psd "-filename<datetimeoriginal" -d DSTDIR/%%f_%Y%m%d_%H%M%S.txt -common_args -r SRCDIR

This does what you want in 2 parts:

1) Creates a same-named .txt file for each .psd image, in the same directory tree as the images.

2) Renames these .txt files according to the original image metadata and moves them to a new directory.

- Phil

Edit: The above command may be difficult to understand because I have used some advanced options to combine two commands into one.  It may be easier to understand the commands separately:

1) exiftool -ext psd -w txt -r SRCDIR

2) exiftool -ext txt -tagsfromfile %d%f.psd "-filename<datetimeoriginal" -d DSTDIR/%%f_%Y%m%d_%H%M%S.txt -r SRCDIR

The only trouble with this technique is that you are only able to process images with one extension at a time.
...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 ($).

Phil Harvey

I realized that I can use another advanced option to make this command work for any file extension:

exiftool -w txt -execute "-filename<datetimeoriginal" -d DSTDIR/%%f_%Y%m%d_%H%M%S.txt -srcfile %d%f.txt -common_args -r SRCDIR

Now this command is certain to be totally incomprehensible, but the idea is that the -srcfile option allows you to process a different file other than the one that was specified on the command line.  Here I use this option to process the associated .txt files.

The only problem I can see now is that you will get left-over .txt files in the source directory tree for any file which doesn't contain DateTimeOriginal information.  You could add a "-filename<filemodifydate" before the "-filename<datetimeoriginal" to avoid this problem by using FileModifyDate (which is always available) for files where DateTimeOriginal doesn't exist.

OK, I think I am done responding to my own posts now.  ;)

- 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 ($).