I'm working on a Windows machine using Exiftool in a batch file, and I'm experiencing some unexpected issues when trying to rename files.
Here's what I'm doing:
(this is based on a discussion in this thread: https://exiftool.org/forum/index.php?topic=5768.0)
I'm using a batch file to rename images by prepending the created date (or if that isn't available, the file modified date) and replacing spaces with hyphens. I'm also adding a letter to the date to specify what kind of date it is (m for modified, c for created).
So an original file name might look like this:
this is a picture.jpg
And the final result after running the batch would be
20140430c_this-is-a-picture.jpg
I began with Phil's suggestion:
exiftool "-filename<${filemodifydate}_${filename;tr/ /-/}" "-filename<${createdate}_${filename;tr/ /-/}" -d %Y%m%d DIR
Which worked great.
I modified it slightly
exiftool.exe -r -IgnoreMinorErrors -overwrite_original "-filename<${filemodifydate}m_${filename;tr/ /-/}" "-filename<${createdate}c_${filename;tr/ /-/}" -d %%Y%%m%%d DIR
But now if it doesn't find the created date, it doesn't return the modified date.
It returns:
c_this-is-a-picture.jpg
instead of
20140430m_this-is-a-picture.jpg
Any insight as to what the problem might be?
Thank you for your time.
This is due you your addition of the -IgnoreMinorErrors (-m) option:
If a specified tag does not exist, a minor warning is issued and
the line with the missing tag is not printed. However, the -f
option may be used to set the value of missing tags to '-' (but
this may be configured via the MissingTagValue API option), or the
-m option may be used to ignore minor warnings and leave the
missing values empty.
- Phil
Perfect, everything's working as expected.
I realize now that what I really wanted was the -q option.
Thanks again!