File wildcard Rename

A swapping-ground for Regular Expression syntax

File wildcard Rename

Postby Wizerd » Thu Aug 07, 2014 8:21 pm

I have files/folders with the following names:

CB5001
CB50011
CB50012
CB5002
CB50021
CB50023
CB55553
I want to find all CB5***1 and have the last 1=A, 2=B, 3=C (note that not all file-names have the 7th character as 1,2 or 3). Resulting in the names below:

CB5001
CB5001A
CB5001B
CB5002
CB5002A
CB5002C
CB5555C

Any help would be appreciated
Thanks
Wizerd
 
Posts: 3
Joined: Thu Aug 07, 2014 8:13 pm

Exchange last digit by a corresponding char I need

Postby Stefan » Fri Aug 08, 2014 10:33 pm

Wizerd wrote:I have files/folders with the following names:
CB5001
CB50011
CB50012
CB5002
CB50021
CB50023
CB55553

I want to find all CB5***1 and have the last 1=A, 2=B, 3=C
(note that not all file-names have the 7th character as 1,2 or 3).

Resulting in the names below:
CB5001
CB5001A
CB5001B
CB5002
CB5002A
CB5002C
CB5555C




Code: Select all
From:       >  To:
CB5001   > CB5001
CB50011   > CB5001A
CB50012   > CB5001B
CB5002   > CB5002
CB50021   > CB5002A
CB50023   > CB5002C
CB55553   > CB5555C


Do three times a regex search and replace:

RegEx(1)
Find: ^(CB5...)1$
Repl: \1A


RegEx(1)
Find: ^(CB5...)2$
Repl: \1B



RegEx(1)
Find: ^(CB5...)3$
Repl: \1C




 Please wait a few seconds then submit. Thank you.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: File wildcard Rename

Postby Wizerd » Mon Aug 11, 2014 10:56 pm

Not sure what could be wrong..but adding the Reg expression and highlighting the list, doesn't give a preview of the new name. This expression seemed to work for the folder names, but not the files under it:

Original:
CB50021-06 - Twain, Shania - I'm Gonna Getcha Good.zip

Should be:
CB5002A-06 - Twain, Shania - I'm Gonna Getcha Good.zip
Wizerd
 
Posts: 3
Joined: Thu Aug 07, 2014 8:13 pm

Re: File wildcard Rename

Postby Stefan » Tue Aug 12, 2014 6:14 am

Wizerd wrote:Not sure what could be wrong..

Well :evil:

you gave us totally wrong example names in your first post :roll:
Wizerd wrote:I have files/folders with the following names:

CB5001
CB50011
CB50012


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
quote="Wizerd"
Original:
CB50021-06 - Twain, Shania - I'm Gonna Getcha Good.zip
Should be:
CB5002A-06 - Twain, Shania - I'm Gonna Getcha Good.zip
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Do three times a regex search and replace:

RegEx(1)
Find: ^(CB5...)1(.+)$
Repl: \1A\2

RegEx(1)
Find: ^(CB5...)2(.+)$
Repl: \1B\2

RegEx(1)
Find: ^(CB5...)3(.+)$
Repl: \1C\2



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

Re: File wildcard Rename

Postby Wizerd » Wed Aug 13, 2014 7:57 pm

Well I will try and be more specific next time :) Thanks for the help with the RegEx (all 6 of them) - worked like a charm and save me a ton of work.

Cheers!
Wizerd
 
Posts: 3
Joined: Thu Aug 07, 2014 8:13 pm

Re: File wildcard Rename

Postby Stefan » Wed Aug 13, 2014 8:00 pm

Fine! Thanks for the feedback.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions