Autonum between variable length strings /or replacing marker

A swapping-ground for Regular Expression syntax

Autonum between variable length strings /or replacing marker

Postby Legbiter » Wed Aug 14, 2013 11:39 pm

Place or move an auto generated number to a position between Artist/Album strings and Title/extension strings.

Albums with Various Artists present particular difficulties, given the variations in Artist and Song title string lengths, and I have been unable to find or compose a solution for this one.
My programming skills are shakey so even reference to Google, the BRU Manual and Stefan's (brilliant) RegEx Hints has not prodded me to an answer.

Test Selection (where # indicates desired position of autonum 01, 02, . . . etc):
Nightwish [The Best of Gothic Rock] # - Bless the Child.mp3
Within Temptation [The Best of Gothic Rock] # - Running Up That Hill.mp3

What I've tried (and failed with) so far
Added a Prefix Autonumber and attempted to shift it (to position of "-"), using many, many variations of this:
Match String: ^([\d{2})\s([A-Z][a-z]*)\s([A-Z])\s-\s(.*)
Replace String: \2 \3\ 1 \4
Didn't work.

The Manual holds this tantalising quote:
"If you enter the special character ":" (colon) in the "Sep." box then this will be replaced with the autonumber at runtime. So a separator value of ABC:DEF: would result in ABC1DEF1, ABC2ABC2 etc."

With this I thought "Eureka, problem solved", but after trying to get "Sep" to recognise and replace all manner of marker characters/symbols that I inserted (into the string and/or the "Sep" box), nothing has worked.

I conclude that I am missing some small and critical element.
Can someone enlighten me. Please.
Legbiter
 
Posts: 2
Joined: Wed Aug 14, 2013 9:47 pm

Re: Autonum between variable length strings /or replacing marker

Postby Stefan » Thu Aug 15, 2013 8:25 am

>> "enter the special character ":" (colon) in the "Sep." box "

This is only the separator for the digits to enter.

Example:

FROM:
My File name.ext
TO:
1My File name.ext
USE:
Numbering(10)
Mode Prefix
Sep

---

FROM:
My File name.ext
TO:
1-My File name.ext
USE:
Numbering(10)
Mode Prefix
Sep -

---

FROM:
My File name.ext
TO:
01 - My File name.ext
USE:
Numbering(10)
Mode Prefix
Sep 0: -




- - - for your issue, try this:

STEP 1

FROM:
Nightwish [The Best of Gothic Rock] - Bless the Child.mp3
Within Temptation [The Best of Gothic Rock] - Running Up That Hill.mp3

TO:
#1#Nightwish [The Best of Gothic Rock] - Bless the Child.mp3
#2#Within Temptation [The Best of Gothic Rock] - Running Up That Hill.mp3

USE:
Numbering(10)
Mode Prefix
Sep #:#

(by using #:# we are sure to match the right digit in our second step)

Rename.

Disable "Numbering(10)"

---

STEP 2

FROM:
#1#Nightwish [The Best of Gothic Rock] - Bless the Child.mp3
#2#Within Temptation [The Best of Gothic Rock] - Running Up That Hill.mp3

TO:
Nightwish [The Best of Gothic Rock] 1 - Bless the Child.mp3
Within Temptation [The Best of Gothic Rock] 2 - Running Up That Hill.mp3

USE:
RegEx(1)
Match: "#(\d+)#(.+) - (.+)"
Repla: "\2 \1 - \3"

(We match our numbering -dropping the #s- and store it for reuse in group 1. Then we match everything till space-hyphen-space into group 2. Then the rest into group 3.)

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

Re: Autonum between variable length strings /or replacing marker

Postby Legbiter » Wed Aug 21, 2013 2:31 am

Blimmin' brilliant, it's just like magic - Thanks a million Stefan.
I liked the # #, very nice touch. Just the sort of pro-active step that I prefer to add, (once I've managed to think my way through that far, that is).

Not only solved this problem but also lends an understanding for future coding ventures. . .

Cheers
Legbiter
Legbiter
 
Posts: 2
Joined: Wed Aug 14, 2013 9:47 pm


Return to Regular Expressions