how to append metadata to filename

Started by macx979, July 29, 2022, 03:10:08 PM

Previous topic - Next topic

macx979

Hi,

I am using exiftool with this cli command in order to change the filename based on creation date and add the camera model the footage was taken with.
"exiftool.exe" "-filename<${model;} $CreateDate" -d "%Y-%m-%d_%H.%M.%S - %%f.%%e"  -api QuickTimeUTC .The Results looks like this:
HERO9 Black 2022-07-03_13.36.44 - GX011483.MP4
But I rather would like to have the metadata of the camera model between the date and the filename and it should be cropped after HERO9 in this case. So the output should look like this:
2022-07-03_13.36.44 - HERO9 - GX011483.MP4
Whatever I tried it didn't work unfortunately. Either the model is added to the extension or other weird things happen.
Could someone please point me to the right direction?

Best

Phil Harvey

Try this:

"exiftool.exe" "-testname<$CreateDate - ${model;} - %f.%e" -d "%Y-%m-%d_%H.%M.%S" -api QuickTimeUTC .
Here I have moved the filename (%f) and extension (%e) codes out of the date-formatting string and put them in the argument to copy into the filename.

I also recommend using "testname" first (as above) until you get the results you want, then change this to "filename" and run the command again to actually rename the files.

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

macx979

Hey Phil,
great that works well. thx

I also added the cropping of the model name after the first blank.
"exiftool.exe" "-filename<$CreateDate - ${model;s/ .*//} - %f.%e" -d "%Y-%m-%d_%H.%M.%S" -api QuickTimeUTC .
since I add the filename to the output file, each run of this command will - of course - append the current, already processed filename to it.

Is there a way to skip processing a particular file e.g. if the Create Date is already part of the filename or the actual filename is longer than 15 characters etc.?

Phil Harvey

You could do this:

"exiftool.exe" "-filename<$CreateDate - ${model;s/ .*//} - ${filename;$_=undef if length > 15}" -d "%Y-%m-%d_%H.%M.%S" -api QuickTimeUTC .
- 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 ($).