#1 : 09/04-21 07:37 Alton Spencer
Posts: 6
|
Okay, I just took hours to figure out an simple swap issue so now I'm too pooped to figure out this one:
I want to TURN THIS example: The Doors - The Soft Parade - SongfileNumber1234.mp3 INTO THIS: Doors, The - Soft Parade, The - SongfileNumber1234.mp3 This will also apply to the other articles, "A" and "An" although much less urgently And I'll be doing this, in stages obviously, for well over 200,000 files. PLEASE, I'm not too sharp with this stuff and the forum articles are like reading a foreign language so explain it like I'm a 6 year old, lol. Please help, Obi Wan! You're my only hope! -ALS |
#2 : 09/04-21 09:45 David Lee
Posts: 1125
|
Replace method...
Text to be replaced: (The |An |A )(.*?) - Replace with: \2, \1- Occurrence: All Case sensitive: √ Use regular expressions: √ Apply to: Name For a basic introduction to Regular Expressions read the User Guide: www.advancedrenamer.com/user_guide/regular_expresions Explanation: (The |An |A ) : "|" means "OR" so this regular expression will match any of the three words plus a following space. Enclosing in parentheses is an instruction to save the matched characters in a variable \1 "(.*?) -" will match a string of any number of any characters followed by " -". The parentheses mean that the string only is saved in a second variable \2. The character "?" is an instruction for the match ".*" to include the minimum number of characters. This use of the character "?" is not described in the User Guide. By default the modifier "*" is "greedy" and".*" will continue to match characters up until the final instance of " -". adding "?" changes "*" to "lazy" so each match will stop at the next occurrence of " -". Finally you use the variables \1 & \2 in the replacement string. |
#3 : 14/04-21 23:15 Alton Spencer
Posts: 6
|
Reply to #2:
Myyyyyyyy Hero!! THANK YOU SO MUCH! Now I can finally get the final parts of this music database in order!! FAN-TAS-TIC!!! Thanks also for the explanation! It will certainly help going forward! Cheers! -ALS |
#4 : 14/04-21 23:32 Alton Spencer
Posts: 6
|
Reply to #2:
Ahhhh! Realised there is, in fact a problem! EXAMPLES: The Beatles - Eight Days A Week - DISC1234 The Steeldrivers - Can You Run - DISC1235 Tegan And Sara - White Knuckles - DISC1236 BECAME: Beatles, The - Eight Days Week, A - DISC234 Steeldrivers, The - CYou Run, An - DISC1235 TegAnd Sara, an - White Knuckles - DISC1236 Seems it's done this with other titles in my test run moving ANY instance of "a, an, and the" to the end of the section. How do i get around this wrinkle? Thank you a million for you time!! -ALS |
#5 : 15/04-21 00:52 Alton Spencer
Posts: 6
|
Reply to #2:
OKAY AMENDING THE PREVIOUS PROBLEM My mistake was NOT checking "case sensitive" HOWEVER there is still a similar problem regardless EXAMPLES: The Beatles - Eight Days A Week - DISC1234 Tegan And Sara - White Knuckles - DISC1236 BECAME: Beatles, The - Eight Days Week, A - DISC234 Tegan nd Sara, A- White Knuckles - DISC1236 So still fiddling with it, looking for a solution... |
#6 : 15/04-21 01:24 David Lee
Posts: 1125
|
Reply to #5:
I think that you omitted the space after "A" in "(The |An |A )". That would account for "Tegan nd Sara, A". "Eight Days Week, A" is a separate issue - we need to move the article to the end ONLY if it is at the beginning of the phrase - ie either at the start of the filename or else immediately following "- ". It should be possible to do it in one Replace method but I can't sort it out at the moment so a quick workaround will be to use two similar Replace methods to deal with the artistes and the song separately... 1) Replace: ^(The |An |A )(.*?) - 2) Replace: - \K(The |An |A )(.*?) - In each case replace with: \2, \1- as before but use Occurrence: 1st In the first method "^" represents the start of the filename In the second method \K is an instruction to exclude the previously matched characters from the final match. So the article must be preceded by "- " but these characters will not be included in the text to be replaced. |
#7 : 15/04-21 11:26 Alton Spencer
Posts: 6
|
Reply to #6:
Okay! Thank you VERY much! Some file names also needed some minor tweaking but, for the most part, everything seems manageable now. I do have one more minor question about why I cannot replace things in parentheses. GENERAL EXAMPLE: The Beatles - The Long And Winding Road (Remastered) - Disc001 BECOMES Beatles, The - Long And Winding Road (Remastered), The - Disc001 At this point, it's a relatively minor issue which I've decided I can live with since my attempts to replace "(Remastered), The" with ", The (Remastered)" failed and every attempt that came close left "()" in there somewhere. Anyway, thank you a TON for your time and prompt responses! Cheers -ALS |
#8 : 15/04-21 16:43 David Lee
Posts: 1125
|
Reply to #7:
No problem! Change the 2nd Replace method to... Replace: - \K(The |An |A )(.*?) (-|\() with: \2, \1\3 Instead of terminating the match with "-" we use "-" OR "(" In a regex OR is written "|" and parentheses normally have a special meaning so have to be "escaped" with "\" in order to represent themselves. Hence "(-|\()". The enclosing parentheses mean that the matched character is saved in another variable "\3". |