Part of filename to title

Started by fredande42, February 27, 2019, 09:47:48 AM

Previous topic - Next topic

fredande42

I hope someone can help me with a regex solution. I'm trying to add part of a filename structure into DC:title, but I'm not sure how to do it with regex. I have a file name structure for multiple images where the filename can be like this:

one_pic00001.jpg

(my file names are always using this structure, three characters, an underline, three more characters and then five numbers and the extension).

Now what I would like is to strix the first part one_ , and add a space between pic and 00001. I would like the tag Title to be: pic 00001

Do anyone know how to solve this using an regex expression? Grateful for any suggestions.

Phil Harvey

There are many ways to do this.  Here is one:

exiftool "-title<${filename;$_=substr($_,4,3).' '.substr($_,7,5)}" DIR

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

fredande42

Thank you!! It works perfectly! I really appreciate the lightning fast help here. :)