Multiple conditions

Started by Mauricio Villablanca, June 02, 2010, 07:23:30 PM

Previous topic - Next topic

Mauricio Villablanca

First of all, kudos to Phil. This is by far the most advanced exif metadata reader/writer out there. Keep up the good work.

Now, I have a question about the use of multiple conditions. I'm running a batch process that reads metadata from files that do not have a specific name because their tags have already been added to a database. I created the condition -if "not $filename eq 'a.jpg' and not $filename eq 'b.jpg'  .... " but for a big set of files it's not practical. I was wondering if there's a way of using a condition similar to SQL:
-if $filename not in (...)

Also is there a limit in the number of conditions used for -if?

Phil Harvey

You have a number of options (here I am assuming a Unix-based platform. For Windows, the quoting will be different):

Use a regular expression containing all the file names:

-if '$filename !~ /^(a|b|c|d|another).jpg$$/'

Or if there are a very large number you could put them in a separate file (say "files.txt") and do something like this (but it isn't pretty):

-if 'open IN,"files.txt";my @f=<IN>;close IN;grep !/^$filename$$/,@f'

There is no limit to the number of -if options you may use.  (Unless you are in Windows, where I believe there is a limit on the total length of a command line.)

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

Phil Harvey

I just realized after noticing the quoting technique you used in your example that you are probably in Windows, so you should swap single quotes for double quotes and visa versa in my examples.

You can avoid the Windows command-line length limitation by using the -@ option.

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

Mauricio Villablanca

Thank you very much for the suggestion.