Rename files not accessed in the last hour

Started by grimacing-visor, January 27, 2023, 03:59:56 PM

Previous topic - Next topic

grimacing-visor

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

StarGeek

The ShiftTime helper function 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, 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' .
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

grimacing-visor

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.

StarGeek

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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

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