test datetimeoriginal existance

Started by Nexius2, November 20, 2014, 03:56:44 AM

Previous topic - Next topic

Nexius2

hello,
I'm trying to test if datetimeoriginal exists in a file.
probleme is, when it exists, i have a return "xx:xx:xx unknown operand" and when the date doesnt exist, I have "- unknown operand".

this is whath I was thinking of:

if [ -z $(exiftool -f -s3 -"DateTimeOriginal" -Pv "$line") ]
then
echo "no date"
else
echo "date"
fi


any ideas?

Phil Harvey

Try this:

#!/bin/sh
if [ "$(./exiftool -f -s3 -"DateTimeOriginal" "a.jpg")" == "-" ]
then
echo "no date"
else
echo "date"
fi


Also, I'm not sure what you were trying to do with the -Pv, but it wasn't doing what you wanted.

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

Nexius2

yeah ! so happy, thanks !
it worked with
if [ "$(exiftool -f -s3 -"DateTimeOriginal" "$line")" == "-" ]

it's to make a check on a file in case it has no datetime so I can get the folder name and rename the file.

thanks again

Phil Harvey

Right.   Sorry, I forgot to remove the "./" and change "a.jpg" back to "$line". (I usually run tests like this using a local copy of exiftool on a test file called "a.jpg".)

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

Shackers

Could this be achieved at the command line?
Perhaps passing a directory into %1 then ignoring any files with valid DateTimeOriginal & displaying Directory-Filename only for invalid.

this fails
exiftool %1  if [ -f -s3 -"DateTimeOriginal" "$line" == "-" ] then echo "$directory-$filename"

Phil Harvey

On the command line:

exiftool -directory -filename -T -if "not $datetimeoriginal" -r DIR

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

Shackers

thanks Phil
How can I contribute towards the costs of keeping this amazing service of yours going?

Phil Harvey

Thanks for the offer.  There is a "Donate" button on the ExifTool home page just for this purpose. :)

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

Shackers


Phil Harvey

I got the donation.  Thank you very much!!

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