Selecting a year, moving it to the end and adding brackets

Bulk Rename Utility How-To's

Selecting a year, moving it to the end and adding brackets

Postby koocha » Thu Mar 26, 2020 4:56 pm

Hi there.

I've tried with the RegEx and failed.

I've got loads of files with a year in the title. Some are formatted with square brackets and another number, some have no brackets at all.

What I'm after is:

1) the files with the square brackets: e.g. [1234 6.6] to remove the number with the decimal and space, convert the brackets to () and move to the end -> (1234).extension
2) the files without brackets to have them and move the number to the end (end result as above)

I can faff about with other things myself, I'm just stuck with the RegEx. Any help would be appreciated. And yes, I've tried reading the manual and it confused me.

Thanks
koocha
 
Posts: 3
Joined: Thu Mar 26, 2020 4:50 pm

Re: Selecting a year, moving it to the end and adding brackets

Postby koocha » Thu Mar 26, 2020 5:19 pm

Don't worry, I've sorted it!
koocha
 
Posts: 3
Joined: Thu Mar 26, 2020 4:50 pm

Re: Selecting a year, moving it to the end and adding brackets

Postby Admin » Fri Mar 27, 2020 1:01 am

How ? :)
Admin
Site Admin
 
Posts: 2351
Joined: Tue Mar 08, 2005 8:39 pm

Re: Selecting a year, moving it to the end and adding brackets

Postby koocha » Fri Mar 27, 2020 8:54 am

You won't like it...

I did many, many replace commands. Because the number with the decimal ranged from 0.1 to 9.9 and all ended in ] I did something like this:

Replace this -> with this
.1] -> ]
.2] -> ]
Etc

That left me with single digit numbers so I then did as above but without the .

Then I had a few double spaced so replaced them with single spaces.

All the years were formatted with a space between so I then did:

[19 -> (19
[20 -> (20

Then replaced ] with nothing and used the add suffix to put a ) on the end of everything ????
koocha
 
Posts: 3
Joined: Thu Mar 26, 2020 4:50 pm

Re: Selecting a year, moving it to the end and adding brackets

Postby Admin » Sat Mar 28, 2020 1:04 am

8) Nice!
Admin
Site Admin
 
Posts: 2351
Joined: Tue Mar 08, 2005 8:39 pm

Re: Selecting a year, moving it to the end and adding brackets

Postby RegexNinja » Sat Mar 28, 2020 3:54 pm

Hi,
Sorry for not replying.. I was just about to, when your 2nd-post appeared, you beat me by seconds, lol.
Also, I also wasn't sure what you meant by Case2's 'to have them', so I didnt bother.
If you run into this again, try something like:

#1 Regex Match/Replace:
(.*?)\[*((19|20)\d{2}) \d{1,2}\.\d{1,2}\]*(.*)
\1 \4(\2)

#5Remove: D/S=checked, Trim=checked

Results like:
[2011 6.6] ------------> (2011)
abc 1990 11.11 xyz --> abc xyz(1990)
abc[2011 6.6]xyz ----> abc xyz(2011)
abc[1234 6.6]xyz ----> no effect (bad year)

Cheers!
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm


Return to How-To