Is it possible to automatically create keywords based on directory location

Started by Pineapple, February 27, 2020, 11:30:36 AM

Previous topic - Next topic

StarGeek

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.
"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

Pineapple

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


Phil Harvey

Hi Henk,

FAQ 15 discusses makernote warnings.  You can put -F or -m anywhere in the command should you decide to use them.

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

Pineapple

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

Phil Harvey

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

Pineapple

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

Phil Harvey

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

Pineapple

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

Phil Harvey

Hi Henk,

To set Subject from HierarchicalSubject, do this:

exiftool "-subject<hierarchicalsubject" -r DIR

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