Main Menu

Using "if"

Started by Zaka, September 13, 2024, 11:18:32 AM

Previous topic - Next topic

Zaka

Hello! I'm trying to figure out how to use "if" to change the "Date Created" ONLY IF the "Date Modified" is OLDER.

Same for IF the "Date" is OLDER.

I am using Windows if it helps.

Thank you!

StarGeek

The first question you need to figure out is exactly what tags are your "Date Created", "Date Modified", and "Date" are. Whatever program you are using to see these might be pulling the data from more than one actual tag.

Run this command to see all the date/time tags in a file
exiftool -time:all -G1 -a -s file.jpg

Compare these results with your "Date Created"/"Date Modified"/"Date" values to figure out the correct tag names.

The basic if option would be
exiftool -if "$DATEMODIFYTAG lt $DATECREATETAG" "-DATECREATETAG<DATEMODIFYTAG" /path/to/files/

Replace DATEMODIFYTAG and DATECREATETAG with the names of the tag names you figured out.

lt is the Perl operator for a string comparison Less Than. A date of "1990:01:01 12:00:00" is going to be less than a date of "2000:01:01 12:00:00", i.e. it is earlier.

This would be for Windows CMD. Use that instead of PowerShell.
* 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).

Zaka

Thank you for the answer!

I will try that as soon as I can.

Another question would be how do I do this in a directory with multiple folders and files? Do I just set the path to the overall folder?

Like User/Pictures/Example Folder... With the ton of subfolders (in Windows)

StarGeek

* 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).