File name filtering + recursion

Started by mbrijun, July 14, 2020, 04:01:06 PM

Previous topic - Next topic

mbrijun

Hi, I am trying to add metadata to files that match a specific pattern "*_iOS.jpg" and to do that recursively in a directory tree. Is there a way to do that? "-r" wants to receive a directory name, not a filename wildcard. Do I have to combine this with something like "find" and process each discovered file individually?

StarGeek

Use the -if option.  For example
exiftool -r -if '$Filename=~/_iOS\.jpg/i' -Description=Stuff /path/to/files/

It's best not to use something like find and loop over each file.  This is Common Mistake #3.  This means that exiftool will have to be run separately for each file and this will take significantly longer because its biggest performance hit is the startup time.

Another option would be to use find to save all the file names into a temp text file and use the -@ (Argfile) option.  For example
find /path/to/search/ -name *_iOS.jpg >temp.txt
exiftool -@ temp.txt -Description=Stuff

Thinking about it, if it's a lot of files then this might be a bit quicker than the -if option.

You didn't mention your OS but I was guessing Mac because of the iOS pattern and the mention of find.  If you're using Windows CMD, then swap Single/Double quotes.
* 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).

mbrijun

@StarGeek - an excellent, informative answer. Thank you!