News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Exiftool IF statement with difference of 2 dates

Started by xhaloz, March 13, 2019, 11:02:56 AM

Previous topic - Next topic

xhaloz

Hello,

I've lost a lot of exif data over the years.  To combat this, I wanted to rename a files date by it's modify date ONLY if that date is less than lets say 12 months of the create date.

This would allow me to get a good general idea of the time frame of the photo. Most of my photos go into a folder with a recent date because of missing data.  So I end up with 20K photos in 1 Jan 2019 folder.

To be clear I just want to rename the files if the modify date is 12 months or older than the create date. I would get better data this way. Maybe then I can triple stack within bash to get the oldest date IF it's 12 months or older.

Thanks!

Phil Harvey

Do you mean something like this?:

exiftool -if "$filemodifydate ge ${filecreatedate;ShiftTime($_,'1:0:0 0')}" ...

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

xhaloz

Hey Phil,

Thanks for replying. First I want to say I really really like your software.  I've written guides on it over at reddit as well as multiple recommendations.

That aside, I tried your command and received

$modifydate ge ${createdate;ShiftTime($_,'1:0:0 0')}: bad substitution

Any ideas? I am assuming GE stands for greater than or equal to?

Edit, removed the brackets and seems to work.  I'll report back!

Phil Harvey

What OS are you using?  You must swap quotes for Mac/Linux.  (see my sig)
...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 ($).

xhaloz

I see, I am using Linux.  I swapped the quote and the code runs.

I cannot get it to meet the condition though.  I've tried the following

exiftool -if '$filemodifydate ge $filecreatedate' "file.jpg"
exiftool -if '$filemodifydate le $filecreatedate' "file.jpg"

Is there a list of operators such as GE or LE? 

Edit, got it working with exiftool -if '$modifydate lt $createdate' 'test.jpg'

Is there an ELSE operator?

Phil Harvey

OK.  Linux doesn't have a FileCreateDate.  I didn't know exactly what tags you wanted to use, so I guessed at the filesystem modification and creation times.  You need to swap these for the date/time tags you actually want to check.  Use this command to see what is available:

exiftool -time:all -s -G1 FILE

- Phil

Edit: You can google for a list of Perl operators.  There is no ExifTool -else option.
...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 ($).