Removing Numbering from Filenames using EXIFtool

Started by andreitakesphotos, January 17, 2024, 05:05:02 AM

Previous topic - Next topic

andreitakesphotos

Hey everyone,

I'm facing a challenge with my project and could really use some assistance. I'm working on uploading a large number of photos to a website, where the filenames include street names and numbering like "Streetname 1 - Sitename - 1," "Streetname 1 - Sitename - 2," and so on.

I'm using EXIFtool to add descriptions automatically, copying the filename into the description. However, I want to exclude the numbering (e.g., "-1," "-2") from the title in the description. Currently, I'm using the following line:

exiftool "-imagedescription<basename" "-artist=my name" -r folder
Is there a way to modify this command to achieve the desired result of having just "Streetname 1 - Sitename" in the description without the numbering?

Any help or guidance would be greatly appreciated!

Thanks,
Andrei

andreitakesphotos

In the title I meant removing numbering from the description when I copy it with EXIFtool. not from the filename itself.

greybeard

This version assumes they are jpg files:

exiftool '-imagedescription<${filename;s/(.*) - \d+\.jpg$/$1/}' -r folder

You can see the general principle if they are other types of files - or you could make it generic for all file types

EDIT

My command was the Mac version - the following should work for Windows:

exiftool "-imagedescription<${filename;s/(.*) - \d+\.jpg$/$1/}" -r folder

Phil Harvey

Or just use BaseName so you don't have to remove the extension:

exiftool "-imagedescription<${basename;s/ - \d+$//}" -r DIR

- 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 ($).