I'm trying to rename files and to store the base of the new name in the Title tag:
exiftool.exe "-filename<${DateTimeOriginal}-%.c.%le" -d "%Y%m%d-%H%M%S" FILE
exiftool.exe "-title<$basename" FILE
Is there a way of doing this in one exiftool execution? It appears that adding "-title<${DateTimeOriginal}-%.c" to the first command is not available because of the copy number.
Right. The %d, %f, %e and %c are special only when exiftool expects a file name, so they have no special meaning when writing Title. And the special characters are interpreted in the file name much later in the processing, after Title is written. So unfortunately I can't think of any way to do what you want in a single command.
- Phil
I would have tried the -execute option. Is that not applicable in this case?
Jim
Thank you for confirming that, Phil.
Jim, I did try various combinations of options and -execute, but without success.
Keith
Jim is correct that any number of commands can be executed in one command line with -execute. The number of processing steps is the same, but the startup costs of the extra command are avoided. In this case, however, determining the file name in advance for the 2nd command would be a problem, unless you can specify a directory name (to process an entire directory of files) instead of a file name on the command line.
If you wanted to be really sneaky, you could do something like this:
exiftool.exe "-celltowerid<directory" "-filename<tmp/${DateTimeOriginal}-%.c.%le" -d "%Y%m%d-%H%M%S" FILE -execute "-directory<celltowerid" "-title<basename" -celltowerid= tmp
Which stores the directory name temporarily in an obscure XMP tag (CellTowerID), then moves the file to a directory named "tmp" and renames it, then adds the Title tag and moves the file back to the original directory in the 2nd command. This won't be much faster though, because it involves writing the file twice (instead of just renaming once and writing once).
- Phil
Edit: Added sneaky command
Edit2: Removed "$" from "basename" (not necessary when just copying a tag directly)
Edit3: Just for fun I tried this command, and realize now that it will duplicate the file twice since it edits some tags each time. Adding -common_args -overwrite_original to the end of the command (as if it wasn't complicated enough already) will delete the originals after each step.
Wow! That's impressive. I think I'll stick with two commands, if only to avoid confusion if I have to amend it in the future. I've learned a lot about -execute though!
Keith
:) I, too, wanted to say thank you for this post and particularly the detailed answers and explanations by Phil/Jan I am in the same situation as the MacOS Finder Created dates changed as the result of writing metadata to file in LR after keywording digital graphic design images. I can use the commands here (I hope!) to fix these dates {incidentally} by fixing the Modified Finder dates. It will save a ton of time and pacify my OCD issues.