Main Menu

embed directory name

Started by Rob Howarth, May 09, 2020, 11:04:29 PM

Previous topic - Next topic

Rob Howarth

Hi all.

I'm trying to build a script that extracts data from a directory of photographs. The photos all have EXIF keywords attached.

I have the following two files...

metadata.format
<a href="${Directory}/${FileName}" class="photo"><img src="${FileName}" height="$ImageHeight" width="$ImageWidth" /></a>

metadata.et
exiftool -p metadata.format -fileOrder ImageHeight ./ >> output.html

Using the ${Directory} command returns '.'. What I would like, if possible, is to return the directory name.

Is this possible? If so, how?

regards,

StarGeek

The Directory tag would return a dot . when you are running exiftool from the same directory as the files.

If you want the full directory path, use can use $FilePath instead of ${Directory}/${FileName}.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Rob Howarth

Cool. Is there anyway I can just get the directory name rather than the whole filepath?

Are there any switches I can use?

thanks,

Under linux command line I would use something like this to return only the directory name.

result=${PWD##*/}
echo $result

StarGeek

You can use some regex to drop the filename
${FilePath;s(/[^/]*$)()}
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Rob Howarth

Thanks StarGeek.

I actually only want the current directory name - not the whole file path. Is this possible?

Eg., /home/rob/Desktop/photoDirectory/test1.jpg

I only want the current directory name. (in bold in this example).

Many thanks for your help so far


StarGeek

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Rob Howarth

Awesome StarGeek  :).

This little snippet from the post you recommended just made my day. Perfect.

${FilePath;$_=(split '\/',$_)[-2]}/

Many many thanks.

regards,