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}.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

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(/[^/]*$)()}
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

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

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Rob Howarth

Awesome StarGeek  :).

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

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

Many many thanks.

regards,