Can't figure this one out...

A swapping-ground for Regular Expression syntax

Can't figure this one out...

Postby chaseweb » Mon Aug 27, 2012 11:45 pm

Hi,

I have 2000 files with the name in the format

CB0000070_(new).mov

I want to remove the _(new) and the result should look like this

CB0000070.mov

anything I put in that should work - it doesn't reflect any changes in the "New Name" column

I have tried

Match: ^(CB.*)(.*)(.mov)
Replace: \1\3

Match: (CB.*)(_\(new\))(.mov)
Replace: \1\3

None are working.

Any ideas

Thanks
Corey
chaseweb
 
Posts: 1
Joined: Mon Aug 27, 2012 11:41 pm

Remove parentheses incl. text between them

Postby Stefan » Tue Aug 28, 2012 1:35 pm

Hi Corey.

1.) please next time use better subjects for your threats so others can find wanted solutions too.
But beside of that you have posted an very clear request with 'before' and 'after' examples
and you also has mentioned what you have tried already. Bravo.


chaseweb wrote:Hi,

I have 2000 files with the name in the format

CB0000070_(new).mov

I want to remove the _(new) and the result should look like this

CB0000070.mov

anything I put in that should work - it doesn't reflect any changes in the "New Name" column

I have tried

Match: ^(CB.*)(.*)(.mov)
Replace: \1\3

Match: (CB.*)(_\(new\))(.mov)
Replace: \1\3

None are working.

Any ideas

Thanks
Corey




2.)
FROM:
CB0000070_(new).mov
TO:
CB0000070.mov
USE e.g.
RegEx(1)
Match: (.+)_\(.+\)
Repla: \1

Explanation:

* Try to match the whole string.
* The part to keep we put in (...) parentheses to capture the match into an backreference, accessible by '\1'

* First we try to match one-or-more of any sign: '.+'
to match the "CB0000070" part.

* Next we try to match an underscore: '_'
followed by an opening bracket: '\('
(which we had to escape, because the '(' had an special meaning. It is an regex meta char),
followed by one-or-more of any sign: '.+'
followed by an escaped closing bracket: '\)'
to match the "_(new)" part.

* Since we don't want to keep the "_(new)"-part, we don't have to store it into an capture group.
* The extension we don't have to take into account!


3.)
And there is an another trick to remind, as mentioned in the help:
"select the files in the NAME column to see what the rule will modify in the NewName column"



4.)
For the examples you have provided you can also use:

Remove(5)
Crop: [Special] [_(*)]


or

Remove(5)
Crop: [After] [_]
and check: [X]Sym. to remove the underscore too.


HTH?

.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions