ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: useidler on June 13, 2016, 01:24:29 AM

Title: put directory name in tag
Post by: useidler on June 13, 2016, 01:24:29 AM
I want to put the bottom directory name into a tag, but it doesn't run (Windows batch for all files in a directory).
e.g.: c:\pics\2012\12\event\picturename.jpg --> event

my code exiftool %path% -L "-Xmp-dc:Title<${Xmp:Title;%tl%;%tu%;%tp%} %%-1:d

What's wrong?

Title: Re: put directory name in tag
Post by: Phil Harvey on June 13, 2016, 08:13:55 AM
The %d etc format codes only work where a file name is expected.  In your case you should use the directory name, and strip off what you don't want, maybe like this:

${directory;s(/$)();s(.*/)()}

This removes the trailing "/" from the Directory name, then removes everything up to and including the last remaining "/".

- Phil
Title: Re: put directory name in tag
Post by: useidler on June 13, 2016, 02:12:43 PM
Hi Phil,

it did work. Thanks a lot! Before I waste 8 hours to find a bug.
In between I thought about the reason you mentioned, but I didn't want to believe it.
The possibility to pick a direct directory level with %d commands looks to sexy.

Ulrich