Check more than 1 file type

Started by edif30, May 25, 2015, 08:22:48 PM

Previous topic - Next topic

edif30

I am trying to do a search and I'd like to check more than 1 file type but I think my syntax is off.  I know very little perl, and that's to say less than minimal. 

This is the command I am running for 1 file type "JPEG"

exiftool -filename -r -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG")' /mnt/nano/photo_backup/ -common -csv > /mnt/nano/photo_backup/noexif_cdates.csv

But I'd like to check on multiple file types.  Would I have to do an or?  Like this?  $filetype eq "JPEG" or $filetype eq "PSD" Or is there a simpler way?  I'd rather specify the file types versus an ALL.  BTW... I am also curious if I can do that as well.  For instance $filetype:ALL.



Phil Harvey

#1
Your syntax looks good to me, and should process the file if the DateTimeOriginal is missing or all zeros, and the FileType is "JPEG".  However, using the -ext option instead of checking FileType would be preferable if the files have the proper extension.  You can use multiple -ext options in a single command.

I don't know what you want to do with $filetype:all, but that won't work.

- Phil

Edit: Added missing word.
...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 ($).

edif30

Thanks

I wasn't sure if the :all would work in that case.  I'll give the -ext a try and see what I can come up with. I guess to be sure I have all the extensions correct I can clean that up and then go back to my search for create date and go from there.

Appreciate the advice!

edif30

Phil,

Before I go the -ext route... Would this work?

exiftool -filename -r -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "JPEG" or $filetype eq "PSD")' /mnt/nano/photo_backup/ -common -csv > /mnt/nano/photo_backup/noexif_cdates.csv

Phil Harvey

Yes, it will work.  I recommended -ext because you can avoid processing the file entirely if it is the wrong type, while the -if condition still needs to read all the tags from the file before it makes its decision.  So -ext is a lot faster.

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

edif30

So if I understand this correctly once exiftool finds the creation date for the specified -ext it will capture what I am searching for and then move onto the next file, versus $filetype reading the entire metadata fields?

Phil Harvey

#6
No.

-ext specifies the files to read.  Then the -if condition is applied only for the files that are read.

So the creation date isn't even considered if the extension doesn't match your -ext option(s).

- Phil

Edit: Fixed typo
...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 ($).

edif30

Got it.  Awesome.  Thanks Phil!