ExifTool Forum

ExifTool => Newbies => Topic started by: grumpy on August 02, 2014, 12:38:27 AM

Title: Date Calculation on IF condition
Post by: grumpy on August 02, 2014, 12:38:27 AM
Hi

Is it possible to test for the condition if two date values are X hours different in the -IF tag?

I want to apply changes only to files that have are more than 8 hours difference in the "trackCreateDate" and "FileModifyDate".

@roscoe:~ ! exiftool ~/Desktop/185.MP4 -trackcreatedate -filemodifydate -ext mp4 -ext mov -ext avi -if '($filemodifydate-$trackcreatedate) gt 8'

Thanks!
Title: Re: Date Calculation on IF condition
Post by: Phil Harvey on August 15, 2014, 07:31:24 PM
Sorry for the delay in responding.  I've been on vacation.

I can think of no simple way to do this.  Doing math with date/time values would take at least a few lines of code, which would make for a very messy advanced formatting expression that would look like this:

exiftool -if '${filemodifydate;my @a=split /[: ]/;$a[0]-=1900;$a[1]-=1;use Time::Local;$_=Time::Local::timelocal(reverse @a)} - ${trackcreatedate;my @a=split /[: ]/;$a[0]-=1900;$a[1]-=1;use Time::Local;$_=Time::Local::timelocal(reverse @a)} > 8 * 3600' ...

- Phil