Replace ( ) in folder Name

A swapping-ground for Regular Expression syntax

Replace ( ) in folder Name

Postby Gilesth » Wed Oct 26, 2016 12:57 am

Hi I have a number of folders in a directory that have a title and at the end the year.

like this
FolderName (nnnn) , where (nnnn) equals a year

I want to rename this to
FolderName [nnnn]

any ideas?

Thanks
Gilesth
 
Posts: 3
Joined: Wed Oct 26, 2016 12:51 am

Re: Replace ( ) in folder Name

Postby KenP » Wed Oct 26, 2016 1:23 am

Assuming that there are no other parenthesis in the title the easiest way in my opinion is with Character Translations.

Special (14)
Character Translations (click on the icon under "Character Translations" and in the text box that opens write 1 character translation on each line as bellow then click OK)
(=[
)=]

Be aware that the character translations stay written until you either delete them or close BRU.

-------------------
If you want to do it with Regex.

RegEx (1)
Match: (.*)\((\d{4})
Replace: \1[\2]
KenP
 
Posts: 199
Joined: Sat Jul 30, 2016 11:25 am

Re: Replace ( ) in folder Name

Postby Gilesth » Wed Oct 26, 2016 1:34 am

There may be more, but it is the last 6 characters I wanted to target.

using this format
(\(\d\d\d\d\))

to
(\[\d\d\d\d\])

Thanks

edit: trying to use, but rename is greyed out. have selected the parent directory and the sub directories i want are displayed in main window and there is a tick in the RegEx (1) box?
Gilesth
 
Posts: 3
Joined: Wed Oct 26, 2016 12:51 am

Re: Replace ( ) in folder Name

Postby KenP » Wed Oct 26, 2016 1:57 am

Gilesth wrote:There may be more, but it is the last 6 characters I wanted to target.

using this format
(\(\d\d\d\d\))

to
(\[\d\d\d\d\])


Sorry I don't understand what you mean, you said in your first post that you want to change the () to [], so changing <example> FolderName (2006) to Foldername [2006].

Both of the options I gave will do that.

Gilesth wrote:edit: trying to use, but rename is greyed out. have selected the parent directory and the sub directories i want are displayed in main window and there is a tick in the RegEx (1) box?

In the folder tree choose the parent directory then in the main window select all the folders you want to change the names of, if the Rename button is greyed out it's probably because the regex code you've put in is wrong so nothing is being renamed.

The code I gave should work with the name format you gave but if you cannot get the regex to work use the Character Translations.
KenP
 
Posts: 199
Joined: Sat Jul 30, 2016 11:25 am

Re: Replace ( ) in folder Name

Postby Gilesth » Wed Oct 26, 2016 2:19 am

Thanks a lot. used the character translation in the end as the RegEx would not work.

I think I have just worked out why, I included the text Match & Replace!

Thanks again.
Gilesth
 
Posts: 3
Joined: Wed Oct 26, 2016 12:51 am


Return to Regular Expressions


cron