Fille missing tag how to fallback to FileModifyDate

Started by unific, June 25, 2025, 10:57:19 AM

Previous topic - Next topic

unific

Hi all, after long time using exif again i am getting error and want to have a fail over CreateDate to FileModifyDate

this is what i am trying but error [minor] Tag 'CreateDate' not defined

exiftool -r -d "H:/Camera/%Y-%m-${FileType}/%Y-%m-%d_%H-%M-%S_[${FileModifyDate}][${Make;}][${Model;}][${Software;}][${FileSize#}][${FileType}]%-3nc.%%e" "-filename<${CreateDate}" *
 
in these files only FileModifyDate are filled but i have a mix off files and need one command for all of them

StarGeek

The format string for the -d (-dateFormat) option cannot contain any actual tags. It can only contain static text, date % codes (see Common Date Format Codes), and filename % codes with the % sign doubled (see the -w (-TextOut) option).

So every tag that you have in the format string needs to be moved to the tag copy operation. Then that needs to be copy/pasted with CreateDate changed to FileModifyDate and placed before the CreateDate copy operation. When a tag (in this case, Filename) is assigned a new value, the last one in the command takes precedence.

Another problem would be that you are trying to include FileModifyDate as part of the date format. But FileModifyDate is affected by the -d option, and would try to include FileModifyDate in the format, which would lead to infinite recursion.

Because you are inserting another tag (FileType) between the two date format codes, the DateFmt helper function will have to be used for one of them.

I'm going to assume that you want FileModifyDate in the %Y-%m-%d_%H-%M-%S format as well. One question would be for files that fall back to the FileModifyDate, do you want it to be repeated or only appear once

Try this. You can replace Filename with TestName to do a dry run and make sure it works first.
exiftool -r -d "%Y-%m-%d_%H-%M-%S" "-filename<H:/Camera/${FileModifyDate;DateFmt('%Y-%m')}-${FileType}/${FileModifyDate}_[${FileModifyDate}][${Make;}][${Model;}][${Software;}][${FileSize#}][${FileType}]%-3nc.%e" "-filename<H:/Camera/${CreateDate;DateFmt('%Y-%m')}-${FileType}/${CreateDate}_[${FileModifyDate}][${Make;}][${Model;}][${Software;}][${FileSize#}][${FileType}]%-3nc.%e" .
"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

unific

Thanks a lot for the detailed explanation and the help!

understand now how the date command is working

I am on windows 11 still get error software also missing
and how to fill in [NO-INFO] if tag not available

Warning: No writable tags set from -/JPG/2017-09-14_09-31-57.jpg 
Warning: [minor] Tag 'Software' not defined - -/JPG/2017-09-14_09-31-59.jpg

Also i want to put take if it in FileModifyDate or CreateDate is used , removed the rest of the tags that not needed

exiftool -r -d "%Y-%m-%d_%H-%M-%S" "-filename<H:/Camera/${FileModifyDate;DateFmt('%Y-%m')}-${FileType}/${FileModifyDate}_[FMOD][${Make;}][${Model;}][${Software;}]%-3nc.%e" "-filename<H:/Camera/${CreateDate;DateFmt('%Y-%m')}-${FileType}/${CreateDate}_[CreateDate][${Make;}][${Model;}][${Software;}]%-3nc.%e" *

could not find it online

unific

i was trying -api MissingTagValue= also did not work

StarGeek

If you need to take in the possibility of any of the tags not existing, then it really isn't feasible to do this on the command line. You would have to make an option for every possible combination of missing tag.

You can't use any of the options that fill in a default option, such as the -f (-ForcePrint) option and the -api MissingTagValue option, because that would also affect the CreateDate tag, meaning you would never fall back to the FileModifyDate.

The best, but more complex, solution would be to create a user defined tag that would build up the filename based upon the tags in the file.

Assumming that the files that have a CreateDate also have all of the other tags, the quick and dirty way would be to run one command for the files with CreateDate (add -if "$CreateDate") and one for those without (-if "not $CreateDate"), with the missing tags removed from the rename.
"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