ExifTool Forum

ExifTool => Newbies => Topic started by: jasonkc on July 03, 2024, 10:18:00 PM

Title: Set Title field from substring of filename?
Post by: jasonkc on July 03, 2024, 10:18:00 PM
I'm trying this to set the title from the filename starting at the 15 character position:

exiftool -overwrite_original "-title<${filename;$_=substr($_,15);s/\.[^.]*$//}" -ext jpg . 

This give me a "bad substitution" error.
Title: Re: Set Title field from substring of filename?
Post by: StarGeek on July 03, 2024, 10:31:11 PM
You don't mention what OS you are using. If you're using Mac/Linux, change the double quotes into single quotes, as the double quotes tell the command line that anything with a dollar sign is the start of a shell variable, not part of the exiftool command.

If you're using Windows Powershell, swich to CMD.

Also, as the thread you originally posted in is very old, it didn't use the Basename tag, which removes the need to trim the extension.

Try
exiftool -overwrite_original '-title<${Basename;$_=substr($_,15)}' -ext jpg .
Title: Re: Set Title field from substring of filename?
Post by: jasonkc on July 05, 2024, 06:44:59 PM
That did the trick! Thank you!