Merge parent folder name?

A swapping-ground for Regular Expression syntax

Merge parent folder name?

Postby coyotewrw » Wed Oct 24, 2007 8:35 pm

Hi all,

I have some folders named "Miscellany", to which I want to add their parent folder's names, ie:

"D:\Music\Beatles\Miscellany" to "D:\Music\Beatles\Beatles Miscellany"
or
"D:\Music\Massive Attack\Miscellany" to "D:\Music\Massive Attack\Massive Attack Miscellany"

Is this possible using Regular Expressions?

Thanks!
coyotewrw
 
Posts: 10
Joined: Thu Mar 02, 2006 6:08 am

Postby Stefan » Wed Oct 24, 2007 9:18 pm

Hi coyotewrw,

1.) select in the left Tree (F11) ""D:\Music\Beatles"
2.) select in the right panel the "Miscellany" folder
3.) Add rule #9 (Append Folder name) as Prefix
4.) use an space as Sep.

You see "Beatles Miscellany" as new name for the "Miscellany" folder.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby coyotewrw » Wed Oct 24, 2007 9:33 pm

Thanks Stefan, that works. :)

However, what do I do if I want to embed the parent folder name? Ie:

"D:\Music\Beatles\0000 - [Misc]"
to
"D:\Music\Beatles\0000 - [Beatles, Misc]"

Can Reg Exp accomplish this?

Thanks again!
coyotewrw
 
Posts: 10
Joined: Thu Mar 02, 2006 6:08 am

Postby Stefan » Thu Oct 25, 2007 7:08 am

coyotewrw wrote:Thanks Stefan, that works. :)

However, what do I do if I want to embed the parent folder name? Ie:

"D:\Music\Beatles\0000 - [Misc]"
to
"D:\Music\Beatles\0000 - [Beatles, Misc]"

Can Reg Exp accomplish this?

Thanks again!


I think RegEx can do this.
You have to know the deep of your folder structure.

--------- "D:\Music\Beatles\0000 - [Misc]"

Search: ([A-Za-z]):\\(.+?)\\(.+?)\\(.+?)\s-\s(\[)(Misc\])

Code: Select all
([A-Za-z])    single drive letter
:           column
\\          single back slash
(.+?)       any char, one or more, lazy i.e. only as many as is it enough => Music
\\
(.+?)       => Beatles
\\
(.+?)       => 0000
\s          space
-           minus
\s          space
(\[)        open [
(Misc\])    Misc]



Replace: \1:\\\2\\\3\\\4 - \5\3 \6

Code: Select all
\1  the catched drive letter
:   
\\  back slash (maybe one back slash is enough while replace???)
\2  Music
\\
\3  Beatles
\\
\4  0000
-
    space
\5  [
\3  Beatles
    space
\6  Misc]


---

But you have nowhere the full path provided to catch the pattern this way.

---

Your solution could be:

First pass:


1.) select in the left Tree (F11) your parent folder "D:\Music\Beatles"
2.) select in the right panel the folder you want to rename "0000 - [Misc]"
3.) Add rule #9 (Append Folder name) as Prefix
4.) use an space as Sep.
5.) increase the amount of parent folders you need
6.) rename your folder to "Beatles 0000 - [Misc]"

Second pass:
7.) now select your folder "Beatles 0000 - [Misc]"
8.) create an RegEx to move "Beatles" where you want it to be like "0000 - [Beatles, Misc]".

---

If this was helpful for you please help two others too.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby coyotewrw » Thu Oct 25, 2007 9:45 pm

@Stefan: Yeah, I did that second solution last night. It took awhile, but it worked. I'll keep the first solution handy for the next time I need to do this.

Thanks again! :)
coyotewrw
 
Posts: 10
Joined: Thu Mar 02, 2006 6:08 am

Postby Stefan » Thu Oct 25, 2007 10:27 pm

You are welcome. Well done coyotewrw :lol:
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions