ExifTool Forum

ExifTool => Newbies => Topic started by: sharpjv on September 24, 2018, 11:16:17 AM

Title: Embedding folder names as keywords
Post by: sharpjv on September 24, 2018, 11:16:17 AM
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
Title: Re: Embedding folder names as keywords
Post by: Phil Harvey on September 24, 2018, 11:27:45 AM
Hi John,

Here is a recent post from someone wanting to do almost exactly the same thing from the file name. (https://exiftool.org/forum/index.php/topic,9536.msg49354.html#msg49354)

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
Title: Re: Embedding folder names as keywords
Post by: sharpjv on September 24, 2018, 11:47:06 AM
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
Title: Re: Embedding folder names as keywords
Post by: Phil Harvey on September 24, 2018, 11:49:01 AM
Hi John,

Yes and yes.  The commands will do that.

- Phil
Title: Re: Embedding folder names as keywords
Post by: sharpjv on September 24, 2018, 01:33:18 PM
Phil - you're a lifesaver! Much appreciated.

Donation will be forthcoming,

cheers

John