Adding conditions to an Exiftool script

Started by pacman, May 12, 2016, 05:17:26 AM

Previous topic - Next topic

pacman

Thanks for checking.
No, the first part (touch -t) is for setting the Creation date (it also sets the Modification date even though that wasn't my aim).
The second part (&& touch "$f") is for setting the Modification date to "now" so backup software can see which files have changed (it's also helpful for me to determine if a file has been fixed or not).

From what I've read, putting && in front of a command on the same line as other commands means that it'll only be excecuted as long as the first command has been run, which should then only set the Modification dates for the files which have had their Creation dates fixed by this script.

Phil Harvey

Right.  I forgot.  You are setting the FileCreateDate via the side effect where OS X doesn't allow the FileModifyDate to be before the FileCreateDate.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

pacman


pacman

#18
Silly me... I could just as well have removed -P (preserve date/time of original file) instead of adding && touch "$f". Either seem to update the OSX file Modification dates.

About conditions.... i've just learnt that some Lightroom users put the different date tags to different uses (i.e. the origin date of a scanned image which would be different from the date it's actually scanned) so I would have to modify my other script (create date/time tags in files that don't have them, and fill them with the OSX file Creation date) to look at each tag individually instead.
Does Exiftool differentiate between a tag being present, but not populated, or are there only two options: present (and populated) or not present at all?

Phil Harvey

Here are some examples:

tag not present: -if 'not defined $TAG'

tag exists but is empty or zero: -if 'defined $tag and not $TAG'

tag exists but is empty: -if 'defined $tag and not length $TAG'

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).