Assigning set of Tags to files based on files names

Started by geolam, February 21, 2016, 06:40:48 AM

Previous topic - Next topic

geolam

I have a large collections of pictures ( > 100 000) organized on directories and sub directories. All pic filesnames have the same lenght (36 char). Each characters specify the content of the named pic .

Goal : based on filenames and with the help of filenames wildcards (i.e. : "1234_ABC??_DEF?675535_?GHI-*.EXT") assign recursively a specific set of Exif data ( Title, Keyword, artist, copyright )out of a manually  selected preset file (CSV ?) for example:

assign MetaTag_file_set1.csv to all files matching ??1*.jpg recursively

or

assign MetaTag_file_set2.txt to all files matching ??2*.tif recursively   

etc ..


Anyhelp ?

Thank you   

Phil Harvey

Sure, you can do something like this to match any arbitrary regular expression in the filename:

exiftool -if "$filename =~ /^1234_ABC...DEF.675535_.GHI-/" -ext jpg -SOMETAG=VALUE -r DIR

In regular expressions, a dot (.) represents any character.  The caret at the start (^) forces the expression to match from the start of the filename.  The only disadvantage of doing it this way is speed, because ExifTool will read every file with the specified extension to extract the tags for the condition.  You may specify more than one -ext option if you wish.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

geolam