I have a bunch of files that look like this: 84920701068_4006138.tif
I want to update (append) the last 7-digits before the extension (4006138) to the Subject field. I've tried this command but I get a "bad substitution" error.
exiftool "-xmp:subject<${filename;$_=substr($_,-7,4)}" -ext tif /Users/stevesmith/Downloads
What O/S are you using? Your command should work for Windows, but you will get "138." written to XMP:Subject.
On Mac/Linux, use single quotes instead of double quotes.
For the last 7 digits of the file name, you should use substr($_,-11,7) (the last 4 characters of FileName are the extension).
- Phil
Mac
I changed it as such and still get the error:
exiftool "-xmp:subject<${filename;$_=substr($_,-7,4)}" -ext tif /Users/stevesmith/Downloads
You still have double quotes, but you should be using single quotes on the Mac.
- Phil