Wildcard in filename question

Started by philbond87, May 01, 2020, 02:47:18 PM

Previous topic - Next topic

philbond87

I'm trying to run a  -tagsFromFile command on a folder of files however I only want the operation to affect filenames in the folder that contain a specific string.

Is that possible and, if so, how would I structure the command?

Thanks,
Phil

StarGeek

As long as you aren't recursing into subdirectories, you can just use the asterisk *.  As an example
exiftool -TagsFromFile /path/to/source/%f.%d -DateTimeOriginal /path/to/target/file*SpecificString*

If you need to affect all files with the specific string in all sub-directories, it's a bit more complex as you can't use the asterisk wildcard (see -r (recurse) option and Common Mistake #2).  It will require the -if option and some sort of pattern matching, usually RegEx.  You use a directory as the target path.  To process the current directory, use a dot .
exiftool -if "$Filename=~/SpecificString/i" -TagsFromFile /path/to/source/%f.%d -DateTimeOriginal /path/to/target/files/

If you're on Mac/Linux, swap the double/single quotes.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

philbond87

Very helpful, thanks for the tips!

philbond87

Ok, of course that worked.

Is there a way to include a conditional?
What I'd ultimately like to do is – in addition to performing the operation on a file with a particular string in the file name – I'd like to ignore a handful of file types (particular extensions).

Thanks again

StarGeek

Just add the condition as show above.  Order doesn't matter for most options, you just can't split options that need an additional argument like -TagsFromFile or -if.  For ease you can just drop it onto the end.

To ignore a filetype, use the -ext (extension) option.  Use two dashes to ignore a file type e.g. --ext avi to ignore avi files.  Though avi files would normally be skipped as they are not editable by exiftool. 
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype