Syntax for conditional date changes

Started by Paul Barrett, February 25, 2017, 03:06:51 AM

Previous topic - Next topic

Paul Barrett

Hi everyone

I have  a number of images in my library that were created by scanning old photo prints from the pre digital era.  Because Some apps i use sort images by the file creation data, these old images appear as new.  I need to correct this but I want to avoid editing files unnecessarily because they will then need to be reindexed by my Synology NAS, which is a long process.

So I need to use a conditional command to update just those images where the dates are out of line.  In pseudo bassic this would look something like this:

If File Creation Date/Time > Date/Time Original then
   File Creation Date/Time = Date/Time Original
   Create Date = Date/Time Original
   Date/Time Created = Date/Time Original
end if


I also have a non date related issue to deal with - deleting unwanted tags.  But this time there's a bunch of OR conditions. The pseudo basic looks like this:

If Person In Image <> Null or Event <> Null or City <> Null or Sub-location <> Null or Province-State <> Null or Country-Primary Location Name <> Null
   Person In Image = Null
   Event = Null
   City = Null
   Sub-location = Null
   Province-State = Null
   Country-Primary Location Name = Null
End if



How do I express those two examples in ExifTool terms please?  I have looked at the documentation but I am struggling.

Thanks for listening and for your help.

- Paul

StarGeek

For the first:
exiftool -if "$FileCreateDate gt $DateTimeOriginal" "-FileCreateDate<DateTimeOriginal" "-CreateDate<DateTimeOriginal"
I'm not sure what tag you want for Date/Time Created, but that's the idea.  Use lt for less than, ge/le for greater/less than or equal to.

To remove the nulls, use -TAG-=, e.g.
exiftool -PersonInImage-= -Event-= -City-= -Sub-location-= -Province-State-= -Country-PrimaryLocationName-=

This won't work if the tag is filled with white spaces instead of nulls.
* 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).

Paul Barrett

Thanks StarGeek

Re the second one, I didn't make myself clear.  My bad.Let me try to clarify

Some of the fields are already populated but only on some of the images.  What I want to do is a conditional test that checks to see if any of the fields are not equal to null.  If they are all null we skip the image. If any of them contains data then all of them should be set to null.  I need to do the conditional test to prevent the whole library being updated, which will result in a reindexing / thumbnail generation on my Synology NAS (which will take 2 days).

I'll need to add switches to suppress minor errors, do the subfolders, suppress copies being created, and define the start folder.  I notice that many of the example put the switches first in the command line.  For some reason I have got into the (bad?) habit of putting them last.  Should I alter my ways?

And thanks again.  ;D

Paul

StarGeek

Quote from: Paul Barrett on February 25, 2017, 12:54:52 PM
Re the second one, I didn't make myself clear. 

No, you were clear, I jumped to a conclusion about what you wanted without reading it as close as I should have.

Try this:
exiftool -if "defined $PersonInImage or defined $Event or defined $City or defined $Sub-location or defined $Province-State or defined $Country-PrimaryLocationName" -PersonInImage= -Event= -City= -Sub-location= -Province-State= -Country-PrimaryLocationName=


QuoteI'll need to add switches to suppress minor errors, do the subfolders, suppress copies being created, and define the start folder.  I notice that many of the example put the switches first in the command line.  For some reason I have got into the (bad?) habit of putting them last.  Should I alter my ways?

If that is where you like them, then that's fine.  It doesn't matter.  I end up with them at the front because I use a text substitution/macro program for many of my commands that I use over and over.  So for me, the basic stuff ends up at the beginning before I add the harder stuff.
* 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).

Paul Barrett

Thank you so much for your help.  It's really appreciated.  I would never have worked that out on my own!

Love this forum.

- Paul