Trying to rename files, but exiftool keeps moving them (& automator question)

Started by nick314, November 03, 2022, 08:46:10 PM

Previous topic - Next topic

nick314

Hello from sunny Athens!

On a mac via terminal, I would like to do the following, and I've semi-succeded. I want to rename several (cr2,arw,nef) files inside multiple folders and the resulting file names to contain the folder name followed by a space and a 4 digit padded {fileindex}. The problem I'm running into is that though the files are renamed correctly, they are moved one level up from their original directory. I would like them to be renamed in-place within their respective folders. Any idea on how to achieve that?

Here is my command so far:
exiftool -v -r '-Filename<${Directory} ${FileIndex;$_=substr('0000'.$_,-4)}.%e' /Users/xxxx/Desktop/Test

My second question is, how can I make this into a right-click macOS Automator action, so that the files are renamed quickly without the use of a terminal window?

StarGeek

Take a look at what happens when you run
exiftool -Directory /Users/xxxx/Desktop/Test

What you'll see is that the Directory tag will have the full directory path and I'm assuming that you only want to have the last most directory name as part of the filename.  So what you would end up with would be changing
/Users/xxxx/Desktop/Test/File.jpg
into
/Users/xxxx/Desktop/Test File.jpg
thus, moving up a directory.

What I think you want would be
exiftool -r '-Filename<%-1:d ${FileIndex;$_=substr('0000'.$_,-4)}.%e' /Users/xxxx/Desktop/Test
When you use %-1:d, that will use the last directory name as part of the filename.  See the "Advanced features" section of the -w (-TextOut) option for details.

You should also use Testname instead of Filename to see what the results would be before actually renaming the file.
"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