I would like to automatically generate keywords into the metadata based on the folder the respected images are located in. For files located in Subfolders a keyword hierarchy should be created.
Would this be possible with Exif?
A basic command to do this could be:
exiftool "-subject<directory" -sep "/" -r DIR
Here I am assuming you want to write the keywords to the XMP:Subject tag.
- Phil
Thanks for your feedback. I am looking to update the "Keywords - Application2 (lptc)" field so that is picked up and can be managed in Lightroom Classic.
Would that work?
Yes, Subject is where Lightroom will look for keywords.
I am getting the following error message after running the command on a specific file [/quote]
C:\Program Files (x86)\Daminion Software\Daminion>"C:\Program Files\EXIF\exiftool.exe" -subject Test import\TestFolder\TestSubFolder\DSC04862.JPG" 0<directory" -sep "/" -r DIR"\\DESKTOP-Q6DIS7K\Users\henkv\Pictures\Edilon
The system cannot find the path specified.
What is this in your command?:
import\TestFolder\TestSubFolder\DSC04862.JPG" 0<directory"
also, this is completely wrong
DIR"\\DESKTOP-Q6DIS7K\Users\henkv\Pictures\Edilon
Maybe try this command instead:
"C:\Program Files\EXIF\exiftool.exe" -subject -sep "/" -r "\\DESKTOP-Q6DIS7K\Users\henkv\Pictures\Edilon"
or maybe
"C:\Program Files\EXIF\exiftool.exe" -subject -sep "/" "Test import\TestFolder\TestSubFolder\DSC04862.JPG"
- Phil
I managed to get it to work and used the following on a test image:
C:\Windows>exiftool "-subject<directory" -sep "/" -r C:/Users/henkv/Desktop/TestSubFolderDesktop/TestDesktopDSC04862.JPG
The keywords are created as individual keywords NOT as a hierarchy. Would you be able to help with that?
Thx, Henk
Enclosed a screen shot
Do you want the full directory path, i.e C:/Users/henkv/Desktop/TestSubFolderDesktop/ to be the hierarchy or just part of it?
If the full path, try this
exiftool "-HierarchicalSubject<${Directory;s(/)(|)g}" -r C:/Users/henkv/Desktop/TestSubFolderDesktop/TestDesktopDSC04862.JPG
That will create this hierarchy
C:
Users
henkv
Desktop
TestSubFolderDesktop
That works really well! :)
I would actually only need just a part of the hierarchy so I guess I just cut it out of: -r C:/Users/henkv/Desktop/TestSubFolderDesktop/TestDesktopDSC04862.JPG. eg I am looking for TestSubFolderDesktop onwards plus potentially any subdirectories in that folder.
Is it possible to write the information directly on the file instead of a sidecar. And advise what the pros and cons are. I need to work on 300K images to put in in perspective so doubling the quantity of files will be significant.
Thanks very much for your help.
You can start from whatever directory level you want by "cd"-ing into that directory and running the command from there using a relative path.
- Phil
Thanks..
Can you aslo let me know if it is possible to write the information directly on the file instead of a sidecar. And advise what the pros and cons are. I need to work on 300K images to put in in perspective so doubling the quantity of files will be significant.
Henk
Hi Henk,
Are these all JPG files? If so, you should write the metadata directly to the file.
- Phil
Hi Phil,
Thanks for that. All the images are .jpg... would you be able to let me know what the script should be in that case... I am a bit of a novice and not sure how to do that and really appreciate your guidance.
Henk
Hi Henk,
All of the commands mentioned in this thread will write metadata to the original image.
- Phil
If you change your directory to the top of your hierarchy, I'd suggest changing the Directory part to this
${Directory;s(^\./?)();s(/)(|)g}
That will drop the leading .| from the hierarchy. Any files actually in the directory you start from will not have a hierarchy added.
Hi,
I am getting many Warnings: eg "Warning: Error rebuilding maker notes (may be corrupt)" but there are several others as well. Can you let me know how/where I build -F into the script to fix these and/or -m to ignore minor errors. Or should I approach it in a different way.
Many thanks,
Henk
Hi Henk,
FAQ 15 (https://exiftool.org/faq.html#Q15) discusses makernote warnings. You can put -F or -m anywhere in the command should you decide to use them.
- Phil
I am running into the issue that the keywords are not visible in Lightroom (mac) after I have refreshed they metadata "Read Metadata from File". However if I import the file again then Lightroom does pick up the keywords?!?!
I thought perhaps the fact that a new file is created by the exiftool command could be the reason and I included "-overwrite_original_in_place" and tried the following:
exiftool "-HierarchicalSubject<${Directory;s(/)(|)g}" -r -overwrite_original_in_place "D:\Foto Test\Foto\IMG_1957.jpg"
Eventhough the command does not create a new file, the keyword is still not visible after metadata-refresh in Lightroom.
Please note that I am running the latest Exiftool on a MS Surface/Windows 10 and the file is on an external HDD. After updating I connect it to iMac and Lightroom Classic (Mac)
Let me know if you can help. Thx
Henk
Hi Henk,
First, on Mac you must use single quotes instead of double quotes around arguments containing a "$". Are you sure your HierarchicalKeywords were written?
I tried this on LR 5.7.1 for Mac, and the HierarchicalKeywords written by ExifTool do show up for a JPG image after I do "Read Metadata from File".
- Phil
Hi Phil,
Please note that I have used Exiftool on Windows to update the metadata of the file which resides on an external HDD. On Mac I am using Adobe Photoshop Lightroom Classic 9.1 for Mac.
I double checked in the command promt (windows) and can confirm that the metadata field Hierarchical Subject on the specific file is updated. The keyword is visible in LR Mac only after importing it. Refresh does not work.
Regards,
Henk
Hi Henk,
OK. This seems like an LR 9.1 problem since it works with LR 5.7.1. I suggest submitting this as a bug report to Adobe.
- Phil
Hi Phil,
I have been in touch with Adobe and they asked me to submit a video demonstrating the issue. They also asked me to test it with another Meta data editing software which I did. I used AnalogExif and added a hierachical keyword, which it wrote to the Subject field and subsequently the refresh in LR did pick up the keyword hierarchy.
Changing the code in Exiftool to Subject instead of HierarchicalSubject did the trick as well.
exiftool "-Subject<${Directory;s(/)(|)g}" -r
At least I have a solution! Can you let me know if there is a more efficient/faster way to copy the info from "Hierarchical Subject" to "Subject" then the above script. I need to do several 100K images so I would like the most efficient way.
Can you also let me know if it is worth addressing with Adobe that they are not picking up the "Hierarchical Subject" field during are refresh?
The Adobe engineer did mention that LR 5.7.1 is a completely different package than 9.2 (the current version)
Regards,
Henk
Hi Henk,
To set Subject from HierarchicalSubject, do this:
exiftool "-subject<hierarchicalsubject" -r DIR
- Phil