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.

Thanks,
Andrea
AndreamaryAsked:
Who is Participating?
 
Dan CraciunIT ConsultantCommented:
I have no idea what Regex engine uses Adobe Bridge.

This *should* work:
Search: 
(\d{3})(.*_)(.*\.jpg)

Replace: 
$1_$3

Open in new window


HTH,
Dan
1
 
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.

Complex.

I'd personally use PERL + have it work the first time.
0
 
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!

Cheers,
Andrea
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.