I have several nested directories
c:/photos/2023/spain/2023 Barcelona/img_1.jpg
c:/photos/2023/spain/2023 Cullera/img_2.jpg
f:/photos/2024/Egypt/img_3.jpg
f:/photos/2021/Vietnam/img_4.jpg
I need to add the last directory name from the path to the -Title tag
How can I do that?
exiftool "-title<${directory;s(.*/)()}" ...
This uses the advanced formatting feature to remove everything up to and including the last "/" in the directory name, then copies that to the Title tag.
- Phil
Note that this command requires that you have either CDed to a directory above the one you want to extract,
cd f:/photos/2024/
exiftool -r "-title<${directory;s(.*/)()}" .
or that you have used a absolute path to the directory
exiftool "-title<${directory;s(.*/)()}" f:/photos/2024/Egypt/
If you cd into f:/photos/2024/Egypt/ and run the command from there then Directory will only contain the dot