Update subject field w/ filename substring

Started by ssmith001, August 23, 2013, 11:35:33 AM

Previous topic - Next topic

ssmith001

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

Phil Harvey

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


ssmith001

I changed it as such and still get the error:

exiftool "-xmp:subject<${filename;$_=substr($_,-7,4)}" -ext tif /Users/stevesmith/Downloads

Phil Harvey

You still have double quotes, but you should be using single quotes on the Mac.

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