ExifTool Forum

General => Metadata => Topic started by: Dal on August 10, 2019, 05:35:46 AM

Title: Append original filename into comments before renaming ?
Post by: 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?

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.
Title: Re: Append original filename into comments before renaming ?
Post by: Phil Harvey on August 10, 2019, 07:13:31 AM
Try this:

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

- Phil
Title: Re: Append original filename into comments before renaming ?
Post by: Dal on August 10, 2019, 10:22:28 AM
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.
Title: Re: Append original filename into comments before renaming ?
Post by: StarGeek on August 10, 2019, 12:12:23 PM
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 (https://exiftool.org/exiftool_pod.html#TAG---VALUE) under TAG assignment.

Finally, make sure you read FAQ #3 (https://exiftool.org/faq.html#Q3) 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.
Title: Re: Append original filename into comments before renaming ?
Post by: jcharmon on August 25, 2019, 02:19:46 PM
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?
Title: Re: Append original filename into comments before renaming ?
Post by: StarGeek on August 25, 2019, 03:18:31 PM
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 (https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata#title), 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 (https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata#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.