ExifTool Forum

General => Metadata => Topic started by: ericconn on November 23, 2020, 02:41:18 PM

Title: Inserting filename into the metadata using %f
Post by: ericconn on November 23, 2020, 02:41:18 PM
I'm trying to insert the filename into the metadata for JPG's with an empty RawFilename field, using the %f wildcard. I'm using the below code, to no avail:

exiftool '-RawFilename=%f' -overwrite_original "C:\Test\Image1.jpg"

I tried it with and without the single quote around the underlined part.

Any suggestions? Thanks.
Title: Re: Inserting filename into the metadata using %f
Post by: StarGeek on November 23, 2020, 03:21:57 PM
The percent tokens (%f, %e, %c, etc) can't be copied to a tag.  They're for use with various file operations and format strings, such as -TagsFromFile (https://exiftool.org/exiftool_pod.html#tagsFromFile-SRCFILE-or-FMT) or -w (textout) (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) options or setting the Filename/Directory pseudo tags.
Title: Re: Inserting filename into the metadata using %f
Post by: Phil Harvey on November 23, 2020, 07:14:54 PM
This should do what you want:

exiftool "-rawfilename<${filename;/(.*)\./ and $_=$1}" FILE

- Phil