regular expression help


#1

I'm worthless when it comes to regular expressions, was hoping someone could help me out.

I'm looking to extract a portion of the full path including filename starting at either \Music\ or \My Music\ and ending prior to the last slash before the actual filename.

Example:
Filename Option A - C:\Documents and Settings\Logan\My Documents\My Music\Dance & DJ\DJ Tiësto\Just Be\01 - Forever Today.mp3

Filename Option B
- M:\Music\Dance & DJ\DJ Tiësto\Just Be\01 - Forever Today.mp3

Result - DJ Tiësto\Just Be

A brief explanation of how the expressions does this would be greatly appreciated as well, I'm working on learning how to create my own.


#2

If you use an action Format value with %_parent_directory%\%_directory% is that what you want?


#3

Not neccessarily, if I have a multipe disc album there could be a '\disc 01' in the path.


#4

When you say start at \Music\ wouln't the result have to be Dance & DJ\DJ Tiësto\Just Be ?
And what would be the result from a path with disc number?


#5

Yes, that is the correct result.

If 'Just Be' were a multiple disc album though, it would return Dance & DJ\DJ Tiësto\Just Be\Disc 01


#6

Expression: ^.?(\\Music\\|\\My Music\\)(.)\\[^\\]+$
Replace with: $2


#7

Perfect, thanks!