I need to increment the date/time of my image files, and rename the files according to the adjusted date/time. How do I do that?
I tried
exiftool -d "%Y-%m-%D_%H.%M.%S%%e" -P "-AllDates+=0:0:0 1:21:0"
but that doesn't rename the file or update the file mod time.
Try this:
exiftool -api globaltimeshift="1:21:0" -d "%Y-%m-%d_%H.%M.%S%%e" "-filename<createdate" "-filemodifydate<createdate" -alldates DIR
This uses the API GlobalTimeShift option to shift the extracted times, then writes them back to the tags referenced by the AllDates shortcut (https://exiftool.org/TagNames/Shortcuts.html), as well as setting the file name and updating the filesystem modification date/time. Note that you don't need to specify a date shift of 0:0:0 if you are only shifting the time.
Note that you should be using %d as above, not %D (see the list of common date/time formatting codes here (https://exiftool.org/filename.html#codes)). Luckily your date/time formatting for the file name is compatible when writing back the date/time tags, or else the command would be a bit more complicated.
Also note that I'm setting the file name and the file modification date/time from the CreateDate metadata, but you can set it from any date/time tag.
- Phil
Thank you!
This works, but reveals a new problem.
When I create the new file, the old one, having a different creation date, is still there in the directory.
- Is there a way to remove the old file after creating the new one with the new mod date?
- Is there a way to specify a new destination directory?
- Is there a way to set the file modification date to the updated date/time?
Quote from: chelmite on December 28, 2022, 01:25:42 AM1. Is there a way to remove the old file after creating the new one with the new mod date?
Add
-overwrite_original to the command.
Quote2. Is there a way to specify a new destination directory?
Add
-directory="some/new/directory"Quote3. Is there a way to set the file modification date to the updated date/time?
Drop
"-filemodifydate<createdate" from the command.
- Phil