Main Menu

Renaming files

Started by fotgrafToday, March 05, 2025, 02:01:21 PM

Previous topic - Next topic

fotgrafToday

After spending several hours testing, I would like to ask for help.

I am trying to go through folders if images and add ,,-,, to the image name if the image had a rating.

Before: 20250109-00001.JPG
After: -20250109-00001.JPG


exiftool ,,-filename<Rating" -r

Works great to rename file with the rating, but can't figure out how to add original name and extension, not the ,,-,,

StarGeek

See Writing "FileName" and "Directory" tags for help on renaming.

Just to be clear, you are only adding a minus sign prefix to the filename if the Rating exists?

You don't mention your OS, which is important.

Assuming Windows CMD (don't use Powershell)
exiftool -r -if "$Rating" -Filename=-%F /path/to/files/

If you are on Mac/Linux, change the double quotes to single quotes.

The %F (capital F) variable holds the filename+extension. This command will prefix any file that contains a Rating with the minus sign.
"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

fotgrafToday

BRILLIANT  :)

Thank you very much StarGeek. This Worked perfectly!

What is the variable for the Rating in a given file if I wanted the Rating to be the prefix to any file?

StarGeek

#3
You would use the name of the tag. But using a tag means that the operation changes from a simple assignment, which uses the equal sign, to a tag copy operation, which uses the greater/less than sign.

Additionally, because there isn't a space to separate Rating from the rest of the text, braces must be used around the tag name

exiftool -r -if "$Rating" "-Filename<${Rating}-%F" /path/to/files/

See FAQ #2 and #3 for the commands used to find the tag names, not tag descriptions.
"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

fotgrafToday

thank you for the quick answer.

I keep getting an error message (MacOSX)

exiftool -r -if '$Rating' -Filename=${Rating}-%F FOLDER
zsh: no such file or directory: -%F

greybeard

Quote from: fotgrafToday on March 07, 2025, 03:37:41 AMexiftool -r -if '$Rating' -Filename=${Rating}-%F FOLDER
zsh: no such file or directory: -%F

How about:

exiftool -r -if '$Rating' '-Filename<${Rating}-%F' FOLDER

StarGeek

Quote from: fotgrafToday on March 07, 2025, 03:37:41 AMI keep getting an error message (MacOSX)

exiftool -r -if '$Rating' -Filename=${Rating}-%F FOLDER
zsh: no such file or directory: -%F

While I did make the mistake of forgetting the quotes, that is not the command I used. Please re-read the very first line of that post.

@greybeard used the correct command for Mac/Linux.
"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