ExifTool Forum

ExifTool => Newbies => Topic started by: Antoine on June 26, 2016, 04:01:46 PM

Title: rename files with directory names
Post by: Antoine on June 26, 2016, 04:01:46 PM
Hello,

Being quite a newbie, I don't manage to find the right syntax for the following project:

I currently have files organised as such:

folder A/folder B/file1.jpg
folder A/folder B/file2.jpg
folder A/folder B/file3.jpg

folder A/folder C/file4.jpg
folder A/folder C/file5.jpg

I would need to automatically rename the files so that they become:
folder B - file 1.jpg
folder B - file 2.jpg
folder C - file 4.jpg

Sorry, but after a few hours of attempts, I still don't manage to find the right command line on. Could anybody please help me?

Thank you very much in advance.

Antoine
Title: Re: rename files with directory names
Post by: Phil Harvey on June 27, 2016, 07:52:48 AM
Hi Antoine,

This will get you close to what you want:

exiftool "-filename=%-1:D - %f.%e" DIR

But it will give "file1" in the name instead of "file 1" (you added a space before the number that I am not doing).

Add a -r to the command to process sudbirectories recursively.  You should try this on a test directory first to be sure it is doing what you want.  (As well, it is a good idea to use TestName instead of FileName in the command to do a test run first).

- Phil