Set Title field from substring of filename?

Started by jasonkc, July 03, 2024, 10:18:00 PM

Previous topic - Next topic

jasonkc

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.

StarGeek

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 .
"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

jasonkc