rename files with directory names

Started by Antoine, June 26, 2016, 04:01:46 PM

Previous topic - Next topic

Antoine

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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).