Remove portion of filename (which isn't always the same)

A swapping-ground for Regular Expression syntax

Remove portion of filename (which isn't always the same)

Postby NewYears1978 » Tue Jan 26, 2016 2:05 am

I have filenames that have languages at the end in Parenthesis like:

Filename (USA) (En, Fr, Jp).zip

I need to remove ONLY the last section of brackets (En, Fr, Jp).zip but they are not always the same, sometimes just (En) sometimes having more in them. Basically, Find (En then remove it and all after.

I have NO clue on the expression, and I have like 8k files =D

The space before the (en needs to be removed too:


Filename1 (USA) (en, Fr, Jp).zip
Filename2 (USA) (en).zip
Filename3 (USA) (en, Fr, Jp, Aus, Ger).zip
Filename4 (USA) (en, Fr).zip

Would become

Filename1 (USA).zip
Filename2 (USA).zip
Filename3 (USA).zip
Filename4 (USA).zip

I tried to use like, Crop Special (*) but I don't know how to ignore the first set of parenthesis..plus there aren't always two sets of parenthesis)
NewYears1978
 
Posts: 3
Joined: Mon Nov 30, 2015 4:37 am

Re: Remove portion of filename (which isn't always the same)

Postby RobsterUK » Tue Jan 26, 2016 10:26 am

You didn't mention whether they always have (USA)
If they do you could use that as a match, something like this:

Match:
(.+)([(USA)]) (.+)

Replace:
\1\2
RobsterUK
 
Posts: 8
Joined: Wed Jan 20, 2016 12:00 pm

Re: Remove portion of filename (which isn't always the same)

Postby hns » Sat Feb 27, 2016 9:58 am

Use following Regular Expression
(.*) \((.*)\)
Replace with:
\1
Hope it helps.
- HNS
hns
 
Posts: 2
Joined: Sat Feb 27, 2016 9:18 am

Re: Remove portion of filename (which isn't always the same)

Postby NewYears1978 » Sun Jul 31, 2016 6:49 am

The solutions worked and I am sorry I didn't say thank you before. It slipped my mind :)
NewYears1978
 
Posts: 3
Joined: Mon Nov 30, 2015 4:37 am


Return to Regular Expressions