ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: keysnapper on June 01, 2022, 04:51:04 AM

Title: Prefix Filename with Foldername
Post by: keysnapper on June 01, 2022, 04:51:04 AM
I am on Linux Mint 20.3 Cinnamon and try to rename files.

I start with
~/Test_start/1900 Deutschland/001.jpg
~/Test_start/1900 Deutschland/1901 Berlin/002.png
~/Test_start/1900 Deutschland/1901 Berlin/003.bmp
and hope to get
~/Test_start/1900 Deutschland/1900 Deutschland - 001.jpg
~/Test_start/1900 Deutschland/1901 Berlin/1901 Berlin - 002.png

My best result of trial and error  is the expression

~/Test_start$ exiftool -r -m -V0 '-FileName<$directory -  %-f.%e' .

but the result is
~/Test_start/1900 Deutschland - 001.jpg/
~/Test_start/1900 Deutschland/1901 Berlin - 002.png/
~/Test_start/1900 Deutschland/1901 Berlin/003.bmp

Why are the renamed pictures moving up 1 level?
Why is bmp not renamed?
Title: Re: Prefix Filename with Foldername
Post by: Phil Harvey on June 01, 2022, 06:43:16 AM
Try this:

exiftool -r -m -v0 '-filename<%-1:D - %f. %e' .

See the -w option documentation for an explanation of %D.

Quote from: keysnapper on June 01, 2022, 04:51:04 AM
Why are the renamed pictures moving up 1 level?

Because $directory contains a "/" -- this causes the file to be moved.  You can use -p to see what is happening:

exiftool -r -p '-FileName<$directory -  %-f.%e' .

QuoteWhy is bmp not renamed?

This is FAQ 16 (https://exiftool.org/faq.html#Q16).

- Phil