ExifTool Forum

ExifTool => Newbies => Topic started by: Nexius2 on November 20, 2014, 03:56:44 AM

Title: test datetimeoriginal existance
Post by: Nexius2 on November 20, 2014, 03:56:44 AM
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?
Title: Re: test datetimeoriginal existance
Post by: Phil Harvey on November 20, 2014, 12:02:47 PM
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
Title: Re: test datetimeoriginal existance
Post by: Nexius2 on November 21, 2014, 04:23:25 AM
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
Title: Re: test datetimeoriginal existance
Post by: Phil Harvey on November 21, 2014, 08:51:27 AM
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
Title: Re: test datetimeoriginal existance
Post by: Shackers on December 03, 2014, 12:27:55 AM
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"
Title: Re: test datetimeoriginal existance
Post by: Phil Harvey on December 03, 2014, 06:01:45 AM
On the command line:

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

- Phil
Title: Re: test datetimeoriginal existance
Post by: Shackers on December 04, 2014, 04:38:17 AM
thanks Phil
How can I contribute towards the costs of keeping this amazing service of yours going?
Title: Re: test datetimeoriginal existance
Post by: Phil Harvey on December 04, 2014, 06:31:30 AM
Thanks for the offer.  There is a "Donate" button on the ExifTool home page (https://exiftool.org/index.html#donate) just for this purpose. :)

- Phil
Title: Re: test datetimeoriginal existance
Post by: Shackers on December 05, 2014, 05:07:01 PM
So there is!
(and it works too)
Title: Re: test datetimeoriginal existance
Post by: Phil Harvey on December 05, 2014, 06:42:23 PM
I got the donation.  Thank you very much!!

- Phil