News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

put directory name in tag

Started by useidler, June 13, 2016, 01:24:29 AM

Previous topic - Next topic

useidler

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?


Phil Harvey

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

useidler

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