MacOS: 12.6.2
Exiftool: 12.52
I'm attempting to rename all the files in the folder based on the DateTimeOriginal but only if the file has not been accessed in the last hour. The rename works fine, I am having some issues with the if statement. I think this is close:
exiftool -if '$fileaccessdate le ${now;ShiftTime($_,"0:00:00 01:00:00")}' '-FileName<DateTimeOriginal' -d '%Y%m%d_%H%M%S%%-c.%%e' .
Any help would be appreciated
The ShiftTime helper function (https://exiftool.org//exiftool_pod.html#Helper-functions) only needs the amount to shift by, nothing else. But it's important to remember that all date/time tags are affected by the -d (-dateFormat) option (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat), including now. It probably doesn't matter in this case because you still have all the digits, but it's something to remember in case you don't include the full time
And I think you mean -1 because a positive shift would place the time stamp in the future.
Finally, remember that the FileAccessDate will be changed when exiftool accesses the file.
exiftool -if '$fileaccessdate le ${now;ShiftTime("-1")}' '-FileName<DateTimeOriginal' -d '%Y%m%d_%H%M%S%%-c.%%e' .
Thanks let me try that. I should have visited this first: https://exiftool.org/Shift.html#SHIFT-STRING
Semi related question. Is there a way to see what the parameters are evaluating to when it's iterating through the images? I tried -verbose and -v5 but that didn't seem to do the trick.
Quote from: grimacing-visor on January 27, 2023, 07:28:38 PMIs there a way to see what the parameters are evaluating to when it's iterating through the images? I tried -verbose and -v5 but that didn't seem to do the trick.
If
-v5 doesn't show it, then I don't think there is, though Phil will have to confirm. He's currently away but should return in the next few days.
If you mean the parameters of the -if option, then what I do is to run the command with -if changed to -p to get an idea of what is going on. This won't necessarily give you a valid expression because the values are inserted literally for -p, but it will at least show you these values. (In the actual -if expression evaluation these are preserved as Perl variables.)
- Phil