Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch rename files regular expression on Mac

Tags:

regex

macos

I'm trying to batch rename PDF files to remove all characters from right to left until a numeric character is reached on Mac OS.

For example:

10002ASmith.pdf > 10002.pdf

1023AJones.pdf > 1023.pdf

The numeric length in the beginning of the files is variable so I figure would be best to have regex rename from right to left until a number is reached.

I know Mac Yosemite comes with batch rename capabilities but didn't see a regex rename option. Is it easy to do this in terminal and if so how, or is there a free program I can use to use a regular expression?

I suppose I just need to know what the actual regular expression would be since I'm far from experienced in regex.

Thank you for help in advance!

Jon

like image 580
Jibes Avatar asked Dec 07 '25 16:12

Jibes


1 Answers

NameChanger sounds like a good fit for this purpose - it's free, and will preview the proposed batch regex rename before applying it.

In the example below, I've used the regex ^(\d+).*, and replaced with $1.pdf.

regex rename

like image 171
ptim Avatar answered Dec 09 '25 04:12

ptim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!