Embedding folder names as keywords

Started by sharpjv, September 24, 2018, 11:16:17 AM

Previous topic - Next topic

sharpjv

Hello
I've been trying to work out how to do this ...
I have a large NAS drive with jpgs held in a variety of folders & subfolders with different names. I need to organise the images, but before I do so, I would like to embed the name of each folder & subfolder from the images file path into keywords within the jpg file itself. eg if an image is in \images\building\maintenance\july2017 I would like to embed separate keywords for 'images', 'building', 'maintenance', 'july2017'

Is this possible with EXIFTOOL? If so, can I do it in a batch way rather than navigating to each subfolder?

many thanks
John

Phil Harvey

Hi John,

Here is a recent post from someone wanting to do almost exactly the same thing from the file name.

For what you want, try this:

exiftool "-subject<directory" -sep "/" -P -r DIR

where DIR is the name of the first directory that you want in the keywords.  (Before running this command you must "cd" to the directory which contains this first directory.)

Note that this will remove any existing XMP Subject tag.  If you want to add to existing tags, use "+<" instead of "<".

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

sharpjv

Thanks Phil - I saw that, but I was wondering if there was a way to do it for all the individual folders that make up the path & also if it can be done recursively (I have over 700 folders/subfolders!)
thanks
John

Phil Harvey

Hi John,

Yes and yes.  The commands will do that.

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

sharpjv

Phil - you're a lifesaver! Much appreciated.

Donation will be forthcoming,

cheers

John