Advanced Renamer forum
#1 : 31/08-15 15:01
Dilip Dabrai
Dilip Dabrai
Posts: 5
I have quite a few file names which have info in brackets about it, sometimes there are more than on sets of these. I would like to be able to remove all the sets if possible please help.


The Game Throw It Up (Feat Lil Jon) (Produced By Lil Jon) (Bonus Track) Djm.mp3
In this case I have 3 sets of brackets I would like to remove all the 3 sets with the text in them.

however in a folder I have files with
1 set
2 sets
3 sets
4 sets
all with text in them and the number of words in each set is variable none of them are same.

Please can someone help me

31/08-15 15:01
#2 : 31/08-15 18:57
Posts: 92
Reply to #1:
Try this Replace Method:

Text to be replaced: (.+?)( ?\(.*?\))+(.*)
Replace with: \1\3
Use regular expression: Tick

31/08-15 18:57
#3 : 01/09-15 05:58
Dilip Dabrai
Dilip Dabrai
Posts: 5
Reply to #2:
Hiya Tester123,
It works. However call me a novice I would like to understand the function of . ?and * so for future use so I can experiment with it for different combinations and also the function of \1\3 please explain or point me in the right direction so I can read and understand about it kindly bear with me as I am a newbie

Thanks again from India
Warmest Regards

Dilip Dabrai

01/09-15 05:58
#4 : 01/09-15 22:45
Posts: 92
Reply to #3:

This is not really the best example to get started on regular expressions as there is one character, the '?', that takes on multiple meanings depending on where it is located. It is an advanced topic and it takes more than a short paragraph to explain it in simple, concise terms so I'm not going to try it here. (I would suggest reading up on 'greedy and lazy quantifiers' for full details.)

I'm a bit short on time, but here's a summary.

Let's start with the search string: (.+?)( ?\(.*?\))+(.*)
And your filename to put things in context:
The Game Throw It Up (Feat Lil Jon) (Produced By Lil Jon) (Bonus Track) Djm.mp3

A few basics first
* A '.' is a wildcard that represents any character.
* The bracket pair '()' is used to group or batch a series of characters together.
* For any character of group, you can specify how many repetitions you want. This is called a quantifier, and it follows the character or group. A '+' sign means one or more repetitions, a '*' means zero or more repetitions, and '?' means zero or one, i.e optional.
* A quantifier can have a modifier to make it 'lazy' (one of the other uses of the '?' symbol), or 'greedy' (the default when the ? is absent).
* A backslash is an escape character.

Let's start with group 1: (.+?)
The brackets define a group. It's the first group, and is called group #1.
The dot means look for any character, and the + means at least one repetition.
The '?' in this case modifies the '+' quantifier and makes it lazy.

The idea of this grouping is to match all characters up to the first space-bracket, i.e. 'The Game Throw It Up'. This is achieved by following up with group 2. Without the '?' lazy quantifier modifier, the '+' quantifier is greedy and would find the entire filename up to the end, because all the characters meet the 'any character' definition of the dot. The '?' lazy modifier makes it stop if the subsequent search characters or groups can be matched.

Group 2: ( ?\(.*?\))+
This is the second pair of brackets so this is group #2.
Notice there is a space after the first bracket (that defines the start of the group). This is literally a space character. The ? in this case is the simple zero or one quantifier. This effectively means the space is optional: it can be present or absent.
Next is '\('. We want to look for a bracket literally. Since the bracket is used to represent a group, we need to escape it with the backslash.
Then it's '.*?' which means any character, zero or more times, but be lazy and stop sooner than later.
This is followed by a literal ')' which is escaped by the '\' character.

In the example, this will capture: ' (Feat Lil Jon)'.
However, we have a '+' quantifier (which in this case is apply to the entire group), which means search for the 'space-bracket-any characters-bracket' series multiple times, but at least once.
So it will also capture ' (Produced By Lil Jon)' and ' (Bonus Track)'.

The idea of this grouping is to capture all the bracket pairs, so they can be ignored later on.

Group 3: (.*)
This 3rd group captures any characters following the last bracket pair, in this case ' Djm'.

The Replace string: \1\3
A group can be referenced using \# (or sometimes $#) where # is the group number.
So \1\3 means: take group 1 and group 3 from the search string, skipping out group 2 (which is the repeating bracket pairs), and we finally end up with the desired result.

01/09-15 22:45 - edited 01/09-15 22:53
#5 : 02/09-15 08:41
Dilip Dabrai
Dilip Dabrai
Posts: 5
Reply to #4:
It is a very good start for me and it helps a lot but the only thing I do not understand your statement
(I would suggest reading up on 'greedy and lazy quantifiers' for full details.)
could you please give a link where I can get to read it.
Warm Regards
Dilip Dabrai

02/09-15 08:41
#6 : 12/09-15 15:14
Posts: 92
Reply to #5:
Quote: "please give a link".
Sorry, I thought it was obvious that research meant use Google (or whatever your preferred search engine is) so I didn't explicitly mention it - that's what I do when I don't know something. Any of the entries found are fine and explain it far better than I could in a short time.

12/09-15 15:14
#7 : 02/10-15 10:03
Takacs Mate
Takacs Mate
Posts: 2

I have lots of files to rename, but I am not good in writing scripts, I think it would be an easy task for you. Please help me.

I would like to delete the first part of lots of files, until the first "-" (this should be also deleted.

An example:

original file name:


it should be end up like this:


the upper / lower cases should not be changed.

Please help me !:)

thanks a lot


02/10-15 10:03
#8 : 04/10-15 10:48
Posts: 92
Reply to #7:

Try this Remove Pattern method:
Pattern: .+-
Use regular expression: Tick

Summary: Look for any character (the dot) at least once (the + sign), followed by a hash (literal character), and remove.

04/10-15 10:48 - edited 04/10-15 10:49
#9 : 04/10-15 22:11
Takacs Mate
Takacs Mate
Posts: 2
Reply to #8:

hi perfect, thanks a lot, it works :)


04/10-15 22:11
#10 : 12/12-16 04:25
Posts: 2
Reply to #8:

nothing's to hard for you, right? though personally, i believe in learning by doing instead being handed every answer. this certainly helped me on at least a couple of issues i was having. thank you & keep up the good work =)

12/12-16 04:25