Cropping file names

A swapping-ground for Regular Expression syntax

Cropping file names

Postby knicuk » Mon Oct 22, 2018 10:40 pm

Hello,

I have around 150 images that need to be renamed, they currently follow this format:
SAMPLE EXAMPLE SHOW-JOHN-DOE-CATEGORY.jpg
EXAMPLE SHOW-JANE-WAYNE-CATEGORYB.jpg
EXAMPLE SAMPLE SHOW-JOE-SMOLE-CATEGORYC.jpg

The expected result is:
JOHN-DOE.jpg
JANE-WAYNE.jpg
JOE-SMOLE.jpg

Basically, any text on or before the first “-” gets removed, any text on or after the third “-” gets removed (except the file extension).

How would I be able to do this on BRU?

Would appreciate any help, thank you!
knicuk
 
Posts: 3
Joined: Mon Oct 22, 2018 10:37 pm

Re: Cropping file names

Postby Admin » Mon Oct 22, 2018 11:51 pm

Hi - are there always 3 - present in the file names and you want to keep the middle part in between - ?
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Cropping file names

Postby knicuk » Tue Oct 23, 2018 7:59 am

That's correct, there's always 3 - present in the file names and I want to keep just the middle part (the name with the - in between).
knicuk
 
Posts: 3
Joined: Mon Oct 22, 2018 10:37 pm

Re: Cropping file names

Postby therube » Tue Oct 23, 2018 4:19 pm

1:RegEx

Code: Select all
Match:  (.*) - (.*) - (.*) -(.*)
Replace:  \2 - \3
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm


Return to Regular Expressions