How to invert two strings

Bulk Rename Utility How-To's

How to invert two strings

Postby inter981 » Sun Mar 15, 2020 1:53 pm

Hi,
hi have around 5000 files with this structure: Name (Publisher)(Year)

Kick Off (Anco Software)(1989)(!).g64

After and before the year, may have more strings, like
Killed Until Dead (Side 1)(Accolade)(1986)(Rl5)(Ntsc)(Patched).g64

Also, if the date is unknown, is shown as "(19xx)" so, will not help only find numerical chars.
Konami Arcade Collection (Side 1)(Konami)(19xx).g64

Is there any way to invert Publisher and year?
I would need:
Kick Off (1989)(Anco Software)(!).g64
Killed Until Dead (Side 1)(1986)(Accolade)(Rl5)(Ntsc)(Patched).g64
Konami Arcade Collection (Side 1)(19xx)(Konami).g64

I will do the same, to move "(Side 1)" string, after the publisher string.

Thank yoy very much!
inter981
 
Posts: 3
Joined: Sun Mar 15, 2020 1:42 pm

Re: How to invert two strings

Postby RegexNinja » Sun Mar 15, 2020 7:06 pm

Hi,

#1Regex Match/Replace:
^(.*)(\(.+\))(\((19|20)\d\d\))(.*)$
\1\3\2\5

Should work fine for dates beginning as either 19xx or 20xx.
You might wanna throw that match into the #12Filter with Regex=Checked
Then hit F5/Refresh to get a better look at your affected files.

If there are names that should not be matched, post back with details & I'll see if I can strengthen the match.
Cheers!
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: How to invert two strings

Postby RegexNinja » Sun Mar 15, 2020 7:47 pm

Hi again,

I just noticed your: "I will do the same, to move (Side 1) after publisher".
In the future, its easier to just post the desired NewNames, instead of an intermediate result.
Its misleading & I have problems sometimes understanding what people want, so just to clarify:

IF (Side x) exists, you would always like it to immediately follow the publisher??
If so, forget the first regex, and use this instead:

^(.*?)(\(Side \d+\)){0,1}(\(.+\))(\((19|20)\d\d\))(.*)
\1\4\3\2\6

Results as below:
Kick Off (Anco Software)(1989)(!) ---------------------------------------> Kick Off (1989)(Anco Software)(!)
Killed Until Dead (Side 1)(Accolade)(1986)(Rl5)(Ntsc)(Patched) ------> Killed Until Dead (1986)(Accolade)(Side 1)(Rl5)(Ntsc)(Patched)
Konami Arcade Collection (Side 1)(Konami)(1972) ---------------------> Konami Arcade Collection (1972)(Konami)(Side 1)

If that's not what you're looking for, please post back with details.. Sorry for any misunderstanding.
Cheers!
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: How to invert two strings

Postby inter981 » Sun Mar 15, 2020 10:07 pm

Strangely does not work with dates (19xx)
Image
:cry:
inter981
 
Posts: 3
Joined: Sun Mar 15, 2020 1:42 pm

Re: How to invert two strings

Postby RegexNinja » Mon Mar 16, 2020 6:38 am

Hi,

Sorry about that, I designed it that way on purpose.. I thought you meant 19xx = 19Any2Digits.
Told you I have problems understanding sometimes (actually quite often).. Sorry.
To include occurences of 19xx

^(.*?)(\(Side \d+\)){0,1}(\(.+\))(\((19|20)(\d\d\)|xx\)))(.*)
\1\4\3\2\7

Same results, also capturing (19xx)
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: How to invert two strings

Postby RegexNinja » Mon Mar 16, 2020 8:48 am

It just dawned on me.. You might have already renamed everyhing except the 19xx files??
If so, use this to only rename the 19xx (or 20xx) files:

^(.*?)(\(Side \d+\)){0,1}(\(.+\))(\((19|20)xx\))(.*)
\1\4\3\2\6
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: How to invert two strings

Postby inter981 » Mon Mar 16, 2020 9:23 pm

Worked perfect!
thank you very much
inter981
 
Posts: 3
Joined: Sun Mar 15, 2020 1:42 pm


Return to How-To