News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

commandline pattern matching

Started by stackfl0w, March 30, 2020, 04:11:32 AM

Previous topic - Next topic

stackfl0w

So my files are named img_YYYYddmm_HHMMSS.jpg and I'm trying to conditionally decide to only process those files that match that format. I try:

exiftool -if "${filename=~/\D+\d{8}_\d{6}\D+/}" (dostuff) ./tmp

But all files fail the condition. I can try making it a substitution with s/// and get it to work but is that really necessary? Any tips?

Phil Harvey

Your expression has a syntax problem.  The regular expression should be outside the braces:

-if "${filename}=~/\D+\d{8}_\d{6}\D+/"

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


stackfl0w

Hey quick question, do elseif statements not work with config files? I always get an error if I try to use any. Don't know if I'm just doing something wrong since I'm new to perl syntax. For instance:


if (expression){
     dosomething;
} elseif (expression){
          dosometehingelse;
          }


Always returns a syntax error. I don't recall the documentation noting it, if I'm mistaken my apologies :)
There's other ways but this is just convenient lol

StarGeek

Quote from: stackfl0w on April 02, 2020, 12:24:43 PM
Hey quick question, do elseif statements not work with config files?

elsif, not elseif.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

stackfl0w

Ah, saved again from my carelessness! I need to start paying attention to my P's and Q's. Thanks again!

Phil Harvey

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