Author Topic: Inserting filename into the metadata using %f  (Read 24 times)

ericconn

  • Jr. Member
  • **
  • Posts: 12
Inserting filename into the metadata using %f
« 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.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 4209
Re: Inserting filename into the metadata using %f
« Reply #1 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 or -w (textout) options or setting the Filename/Directory pseudo tags.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17190
    • ExifTool Home Page
Re: Inserting filename into the metadata using %f
« Reply #2 on: November 23, 2020, 07:14:54 PM »
This should do what you want:

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

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).