How to save file name into metadata?

Started by Jom, July 14, 2019, 02:33:15 PM

Previous topic - Next topic

Jom

Hello.
I'm have file name IMG_0012, but it is not in metadata.
If I rename file, I losse original name.
How to save file name into metadata?

StarGeek

First pick a tag you want to save it into.  Then the command would be
exiftool "-TAG<Filename" <FileOrDir>

According to the IPTC specs, the appropriate place would be IPTC:ObjectName and XMP:Title but Adobe likes to use those for the short description (which should be Headline).  Adobe instead uses XMP:PreservedFileName
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Jom

I means to create my own new tag. I suspect this is impossible?

StarGeek

It is very much possible.  See the example config file and also search these forums for more examples.

But why would you want to when there are already several tags specifically for this purpose.  There are few benefits and many disadvantages.  You have to decide what type of tag it is.  You have to create the entries for it in a config file.  And no program other than exiftool will be able to work with it.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Jom

Quote from: StarGeek on July 14, 2019, 04:06:55 PM
But why would you want to when there are already several tags specifically for this purpose.
What are tags? Other programs won't touch them?

Quote from: StarGeek on July 14, 2019, 04:06:55 PM
You have to decide what type of tag it is.
Don't quite understand what you mean? How am I supposed to choose?

Quote from: StarGeek on July 14, 2019, 04:06:55 PM
You have to create the entries for it in a config file.  And no program other than exiftool will be able to work with it.
Need a way without special settings. Everything should be by default.

StarGeek

Now I'm confused as to what you're actually asking.  First you say
Quote from: andreikorzhyts on July 14, 2019, 03:49:24 PMI means to create my own new tag. I suspect this is impossible?

Then you say
Quote from: andreikorzhyts on July 15, 2019, 02:17:35 PM
What are tags?

So, to get to the basics, TAG is the term exiftool uses for a piece of metadata.  This can be as simple as the name of the file or as complex as the structured embedded data to describe the region returned by a facial recognition program.  They can be taken from the underlying OS (filenames, file time stamps, the various Mac OS MD data), properties of the file (image width/height, sound file sample rate), or embedded within the file (various exif data from a camera).

QuoteOther programs won't touch them?

No piece of embedded metadata is untouchable.  Whether other programs touch them or not depends upon how well the program was designed.  Some are more fragile than others.  A couple of examples.  In jpeg files there is the Comment field.  Many programs will overwrite this tag without regards for the previous contents.  Another example is the Windows program Irfanview.  It can be used to edit tags in the IPTC group but doesn't properly deal with a lot of those tags and will delete them.

Most well known commercial programs, such as Adobe Lightroom, won't make unwanted changes to the data, but the more obscure a data type is, the more likely it is be lost.  A home brewed tag falls into this category.

Quote
Quote from: StarGeek on July 14, 2019, 04:06:55 PM
You have to decide what type of tag it is.
Don't quite understand what you mean? How am I supposed to choose?

Various tags belong to groups that detail how they are written.  For example, in image files, you'll find the most common types are EXIF, which usually is data written by the camera detailing how the image was taken, IPTC (aka IPTC IIM/Legacy), and XMP (which contains IPTC Core metadata).  In sound files you'll find ID3v1 and ID3v2 tags. 

But the point I was making is that trying to make your own tag means you have to learn all about what these various groups are and what group would be best for the tag you decide to make.

Now, having glanced through your other thread, I think what you actually wanted to ask was if there was a way to get the original filename even if the filename was changed.  The answer is no.  But you can take the time to embed the filename in the file yourself.  The filename is by design not meant to be immutable.  Which is why I suggested copying the filename into the IPTC:ObjectName, XMP:Title, or XMP:PreservedFileName tags.  This is actually the very first thing I do when I move images from the camera to my computer.  This is because at one point I was dealing with some files from a friend and I didn't realize that there was something faulty with the clock on his camera.  All the file got renamed based upon the embedded date which was something like 1980-01-01 00:00:00. That was a real mess.

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Jom

Thanks for explanation. Much became clear.

I don't know English and many features of my questions I can't state accurately.
Very often I find it easier to understand of logic on the example.

QuoteBut you can take the time to embed the filename in the file yourself.
Yeah, that's what I need.

I want to create a manual for organizing files of my photo shoots. At the heart of all is the name of the file, but to create a universal algorithm was a difficult task. I searched for a long time and chose ExifTool to solve this problem in my process.

1. Plese, I'd like to see the command you use to write the file name to the metadata.

2. IPTC:ObjectName, XMP:Title, or XMP:PreservedFileName — where can I see them?
I'm using exiftool -G ..., but I don't see the IPTC group in the tag list. I see only [ExifTool], [File], [EXIF], [XMP], [MakerNotes] and [Composite] groups.

StarGeek

Quote from: andreikorzhyts on July 15, 2019, 06:12:24 PM
1. Plese, I'd like to see the command you use to write the file name to the metadata.

The first command I run is similar to this.  The actual command is a bit different as I use an exiftool shortcut in my config file, but this is the equivalent
exiftool -r -P -overwrite_original -wm cg -progress "-IPTC:ObjectName<Filename" "-XMP:Title<Filename" "-XMP:PreservedFileName<Filename" DIR

This will go through the entire directory and subdirectories (-r option), preserve the filesystem timestamps (-P (preserve) option), not overwrite existing tags, just in case I'm making a mistake and re-running the command on already processed files (-wm (writemode) option).  It will copy the Filename to all three of the previously mentioned tags.  Personally, I would like to drop the IPTC tag (actually I'd like to drop all IPTC tags) but my favorite image viewer doesn't let me see XMP metadata, only IPTC and EXIF.  For anyone who uses Lightroom/Photoshop a lot, I'd probably suggest only writing to XMP:PreservedFileName.

Quote2. IPTC:ObjectName, XMP:Title, or XMP:PreservedFileName — where can I see them?
I'm using exiftool -G ..., but I don't see the IPTC group in the tag list. I see only [ExifTool], [File], [EXIF], [XMP], [MakerNotes] and [Composite] groups.

They won't exist until exiftool (or some other program) creates them.  Most cameras will only write EXIF data.  A few will also write some XMP data.  I think some iPhones which embed Face Regions do this.  I don't think any camera ever wrote ITPC data.  Most of the XMP and IPTC data are things that get added afterwords during processing/sorting.  Things like location names (GPS will be part of EXIF if it's captured), descriptions, and keywords.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Jom

Quote...just in case I'm making a mistake and re-running the command on already processed files...
I can't understand what you're doing here. Can you put it in other words? Why are you making a mistake?

StarGeek

Sometimes I make mistakes.  Just in case I make a mistake and try to write the filename into a file that I've already done so, the -wm cg option will not overwrite it.  -wm cg will only create new tags and will not write to tags that already exist.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Jom

QuoteJust in case I make a mistake and try to write the filename into a file that I've already done so, the -wm cg option will not overwrite it.
If I understand correctly, is this a test?

1. If I understand correctly, you cannot create a tag BLA:BlaBlaBla?
2. IPTC:ObjectName, XMP:Title, XMP:PreservedFileName — are these special tags for this purpose?
3. There are only three such tags?
4. Why do you write data in three tags at once?
5. I have to watch itself, so that other programs don't change these tags later?

StarGeek

Quote from: andreikorzhyts on July 15, 2019, 10:40:17 PM
1. If I understand correctly, you cannot create a tag BLA:BlaBlaBla?

You can't just create a random tag name.  Exiftool has to already know about it (see the Tag Names page for all the metadata groups and the tags which are part of those groups) or you have to create a new definition (see the example.config file).

Quote2. IPTC:ObjectName, XMP:Title, XMP:PreservedFileName — are these special tags for this purpose?

The first two are tags that have been defined by the IPTC (International Press Telecommunications Council).  XMP:Title is defined here as part of the IPTC Core.  That entry also lists the old IIM entry under "IIM Specs".  IIM (Information Interchange Model) is what exiftool refers to as IPTC. 

I'm not sure of the origin of XMP:PreservedFileName but Adobe uses it to store the original filename.  While technically this should be covered by XMP:Title, as defined in the above link, Adobe decided to use XMP:Title as the short description, specifically going against the spec.

Quote3. There are only three such tags?

The stock image company GettyImages has designed their own tags for this purpose, XMP:CameraFilename and XMP:OriginalFileName.  I'm am not aware of any program outside of GettyImages that actually uses this tag.  Adobe also has XMP:RawFileName, of which I know nothing.

One thing I should be clear on is this.  It's your data and your images.  You can put your data where ever you want to.  The guidelines are there to make it easier for programs to deal with your data, but if you want to do something different, for example, use a time stamp to keep track of the number of monkeys in an image, you can do that.  (Yes, an absolutely silly example.) You just have to know how it will affect any program you use to deal with that image.

Quote4. Why do you write data in three tags at once?

I do it for maximum compatibility.  One program I use, Irfanview, doesn't display XMP data, so that requires IPTC:ObjectName.  I occasionally use Lightroom, so that uses XMP:PreservedFileName.  My DAM (Digital Assets Magangement) will read XMP:Title.  If I ever get around to looking for a replacement for Irfanview that I like, I'll be removing IPTC data from my images and only dealing with XMP from that point.  It's a better standard, but still not universally supported.

Quote5. I have to watch itself, so that other programs don't change these tags later?

It would be something I would watch for when first testing a new program, but it shouldn't be a problem with most commercial programs.  But there is never a guarantee.  All embedded metadata is changeable.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Quote from: StarGeek on July 16, 2019, 12:40:46 PM
if you want to do something different, for example, use a time stamp to keep track of the number of monkeys in an image, you can do that.  (Yes, an absolutely silly example.)

Not silly at all:

> exiftool wheelbarrow.jpg -datetimeoriginal
Date/Time Original              : 8 monkeys


- Phil



Edit: OK.  Maybe a little bit silly.
...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 ($).

StarGeek

LOL, I had an idea how to do it.  Leave it to you to actually do it.  (if that's what you actually did)
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

(download the picture and check the metadata) ;)

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