Finding correct regular expression to batch rename 130 files

I am using Adobe Bridge to batch rename 130 files in a folder. It can handle regular expressions, so I am looking for the correct expression to achieve the following:

Original filename formats:
127155aaaa_58_Road to Cottage Lake Black.jpg
001000_Cottage Map.jpg

Description of revised filename:
Starting from left of entire filename -- Retain first 3 numbers of original filename
Starting from the left of '.jpg' file extension -- retain all text and spaces to left, up to and including the first instance of "_"
Retain ".jpg" file extension

Desired filename after batch renaming:
127_Road to Cottage Lake Black.jpg
001_Cottage Map.jpg

I hope I've provided enough details.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
This is a fairly complex regular expression.

Easy to do in PERL.

In Adobe... Whew... Likely best to rename each file with a set of regular expressions, each rename pruning cruft, till only your desired text remains in each file.


I'd personally use PERL + have it work the first time.
Dan CraciunIT ConsultantCommented:
I have no idea what Regex engine uses Adobe Bridge.

This *should* work:


Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AndreamaryAuthor Commented:
For some reason my comment didn’t show up, so I’ll write it again...

You’re solution works perfectly, Dan - thanks very much!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.