Hi
Another newbie question. I'm confident that this can be done. My image files (all from scans) have non-date data of interest, which is embedded in the filename. The data I'm interested in consists of some text of variable (but predictable) length being the original media type (eg "Slides" or "Negatives" or "Prints"); a film reference number which is a 12-digit string of the form "NNNN_Film-NN" and a frame number which is always two digits long "NN"
So an example filename looks like this: Slides 5423 Film_02 02.jpg
So what I want to do is copy the part of the filename before the extension and then write it unaltered into a tag which will have to be created as it will not exist. The name does not need to be transformed. The one that I think will work best is
ImageUniqueID
which takes a string. So the exiftool command I think is
exiftool '-ImageUniqueID+<filename' DIR
Can it be that simple? Can't test it just now as I'm busy with "proper" work :) but a sanity check welcome.
Almost. The plus sign (+) is used to add a value to a list type tag, such as Keywords, or to shift the value of a numeric tag, such as DateTimeOriginal. For basic text it will respond with a "Warning: Shift value for TAG is not a number" and "Warning: No writable tags set". So remove that and the command should work.
Since you're just copying the filename, might I suggest IPTC:ObjectName or XMP:Title as I believe that is what those tags are designed for. ImageUniqueID (and some similar tags) are (I think) used by programs such as Lightroom and if you start using such a program in the future, there may be unexpected results.
Edit: Sorry, forgot you want to drop the extension. See this previous post (https://exiftool.org/forum/index.php/topic,6192.msg30588.html#msg30588) by Phil for a couple of options on removing the extension.
Thanks StarGeek, that works without the + sign and takes XMP:Title as the target. It does copy the whole filename including the extension to that tag.
I tried using BaseName:
exiftool '-XMP:Title<BaseName' DIR
but it doesn't change anything ("nn image files unchanged")
Not sure what I'm doing wrong here. I've downloaded, saved and renamed the sample config file which includes the definition for BaseName.
Take a look at FAQ 11 (http://www.exiftool.org/faq.html#Q11) to see about getting the config file to work. It makes for a much easier to understand command.
But if you can't, try this command
exiftool '-XMP:Title<${filename;s/\.[^.]*$//}' DIR
Thanks, all seems OK. The bit about environment variables is for Windows, I'm on a Mac. Which specific folder should the config file be in?
The config file should be in your user's home directory (~). Don't forget the leading . in the filename :)
Ah right, not in a subfolder or anything. That's fixed it:
Title : Test 1983 Film_06 29
Thanks very much
Or maybe not. :(
Just run it again on a whole batch of files and the XMP:Title tag isn't appearing but I've now got one called Base Name. I can live with it (don't mind which tag it uses) but if it's unpredictable that's a bit of a worry.
Base Name : Slides 2155 Film_88 27
BaseName is a user-defined Composite tag in the example config file. It is derived from FileName.
- Phil
Hi Phil, I was wondering why I got the XMP:Title tag in the test I did then Base Name as the tag in the batch which used the same exif command:
exiftool '-XMP:Title<BaseName' -overwrite_original DIR
?
I'm afraid you lost me. What were the commands and output?
- Phil
Well, I'm aware that this seems unlikely (differing behaviours) so I think I must have done something different, but what I attempted to do was this:
TRIAL RUN
exiftool '-XMP:Title<BaseName' -overwrite_original FILE
produced a tag in the file called "Title" containing the filename without the extension. This was the desired result so I went ahead and ran it
Title : Test 1983 Film_06 29
EXECUTION
exiftool '-XMP:Title<BaseName' -overwrite_original DIR
produced a tag in every file called "Base Name" containing the filename without the extension. The XMP tag isn't there at all.
Base Name : Slides 2155 Film_88 27
As far as I can tell the files are otherwise identical in that they were all produced by the same scanner and scanning software and have all been similarly touched by exiftool previously to set the createdate etc. The commands were run in Terminal, not script.
Ah. I think there is some confusion here.
You can't create the BaseName tag. The difference is that if you have the example config file installed, then the BaseName tag will be generated when extracting information. So the only remaining question is why (apparently) didn't the second command write the XMP:Title tag? If it didn't write this, ExifTool should have reported "0 image files updated".
- Phil