Strip characters off the end of filenames

Started by jdonalds, June 16, 2016, 02:44:47 AM

Previous topic - Next topic

jdonalds

I ran exiftool on many files and marked the files as changed by adding "_TX: to the file name. Now that I've completed my work I want to strip the "_TX" off the file name. I'm doing this in Windows.

Would someone please supply the exiftool string to accomplish this task. I'm pretty new at this and can't figure it out. If you give me the basics I can likely go from there.

Examples:

     abc_TX.jpg edit to be      abc.jpg
xxxxxx_TX.jpg edit to be xxxxxx.jpg

etc. etc. etc.

Thank you.

Hayo Baan

How about this:
exiftool "-filename<${filename;s/_TX(\.[^.]*)$/$1/}" FILESorDIRS
This will replace _TX before the filename extension (which can be anything) with nothing.
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

#2
Alternatively to remove the last 3 characters from the file name regardless of what they are, and apply this only to "*_TX.jpg" files:

exiftool -filename=%-.3f.%e *_TX.jpg

(I know this wildcard will do what I want on Mac/Linux, but I'm not 100% sure about this for Windows.)

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

jdonalds

Quote from: Hayo Baan on June 16, 2016, 02:56:37 AM
How about this:
exiftool "-filename<${filename;s/_TX(\.[^.]*)$/$1/}" FILESorDIRS
This will replace _TX before the filename extension (which can be anything) with nothing.

Brilliant! After testing I ran this on 3400+ files and it worked perfectly. Now I can run it on the bulk of my photo files.

I do so much appreciate the quick responses and support from this board. It would have taken me days to come up with something.

Thank you so much.

John

Hayo Baan

Excellent, good to hear it worked well for you :)
Hayo Baan – Photography
Web: www.hayobaan.nl