Append original filename into comments before renaming ?

Started by Dal, August 10, 2019, 05:35:46 AM

Previous topic - Next topic

Dal

Hi is there a way to Append original filename (without extension) into comments (IPTC:Keywords) before renaming the filename to something else?

The append operation looks maybe something like this?

exiftool.exe "-IPTC:Keywords<${IPTC:Keywords}, "File:Filename IMG_7516.jpg

But I can't seem to get it working? Any tips?

Thanks.

Phil Harvey

Try this:

exiftool "-keywords+<${filename;s/\..*//}" FILE

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

Dal

Hi.
That seems to work. Thank you for this.

But what if I want to use the Comments field for it instead? With additional text, like "Original Filename: <filename>?

Thanks again.

StarGeek

To set Comment to the filename (no extension) your command would be
exiftool "-Comment<${FileName;s/\..*//}" <FileOrDir>
This will overwrite the Comment if there was already data there.

To append the filename to an already existing tag, you command would be:
exiftool "-Comment<$Comment ${FileName;s/\..*//}" <FileOrDir>
Though this will fail if Comment doesn't already exist.

To combine the two, fill the field if it is empty and add to it if it already has data, you would use
exiftool "-Comment<${FileName;s/\..*//}" "-Comment<$Comment ${FileName;s/\..*//}" <FileOrDir>

This works because latter assignments take precedent, but if it would fail, as the last assignment would if Comment didn't exist, then the previous assignment would take affect.  See Note #1 under TAG assignment.

Finally, make sure you read FAQ #3 to figure out what the actual name of the tag you want to write is.  For example, under Windows Properties->Details, there's a Comments field.  But that Property isn't filled from the Comment tag, it's filled from other tags.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

jcharmon

Quote from: Dal on August 10, 2019, 05:35:46 AM
Hi is there a way to Append original filename (without extension) into comments (IPTC:Keywords) before renaming the filename to something else?

Isn't the Preserved File Name tag (XMP::xmpMM\PreservedFileName\PreservedFileName\0) a better place for this information?

StarGeek

In exiftool nomenclature  that would be XMP-xmpMM:PreservedFileName or more simply just PreservedFileName.  There's no other tag with that name, so there's no chance of putting it in some other location.

It all depends upon what software is being used to read the metadata and what specs you are likely to follow.  According to the IPTC standard, Title (if using modern XMP) or ObjectName (if using IPTC Legacy) would be the proper place.  But Adobe doesn't follow the spec, using those fields for what should be Headline.  So if you're using Adobe software, then PreservedFileName would be the place to put it.  But if your software doesn't read any of those, then you have to put it someplace else if you want to save the data.

But the most important thing, IMO, is getting data you want to save into the image in the first place.  You can always move it later using exiftool.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).