Help replacing special or forbidden characters

LOL–Don’t you just hate miscounting parentheses? I know it always drives me crazy!

I guess I need to do something with the variable as the script works excellent except–now the file is renamed to: E:\Wilfr\My Music-= 1 =–Beatles, The-Help! [1965]-The Beatles - Help! - 1.07 - Ticket to Ride.mp3 instead of E:\Wilfr\My Music-= B =-\Beatles, The\Help! [1965]\The Beatles - Help! - 1.07 - Ticket to Ride.mp3. It looks like it works fine to change the characters though. Just can’t do the slash this way.

Here’s what I used to get this far:

$rreplace(
$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
	$left($if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%),25)/
	$left(%album%,40) [$left(%date%,4)]/
	%albumartist% - $left(%album%,30) - $num(%discnumber%,1).$num(%tracknumber%,2) - $left(%title%,30) [%artist%]
	,
	-= $upper($left($if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%,#),)1) =-/
	$left($if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%),25)/
	$left(%album%,40) [$left(%date%,4)]/
	%artist% - $left(%album%,30) - $num(%discnumber%,1).$num(%tracknumber%,2) - $left(%title%,30)
	)
,[/:],-)

I think I’m beginning to understand this better. Time to investigate the variable option.

Thanx for all the help so far!

Found the error with -= B =- showing as -= 1 =-…I moved the parenthesis between the , and the 1 by mistake. DUH!

HAH! I think it’s working now (I hope). I added the “_” character to my last line and it seems to have solved the probllem…AC/DC is now AC-DC and that works for me!

Here’s my final code…if anyone has any suggestions for improvement please let me know!

$rreplace(

$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
	$left($if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%),25)/
	$left(%album%,40) [$left(%date%,4)]/
	%albumartist% - $left(%album%,30) - $num(%discnumber%,1).$num(%tracknumber%,2) - $left(%title%,30) [%artist%]
	,
	-= $upper($left($if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%,#),1)) =-/
	$left($if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%),25)/
	$left(%album%,40) [$left(%date%,4)]/
	%artist% - $left(%album%,30) - $num(%discnumber%,1).$num(%tracknumber%,2) - $left(%title%,30)
	)
,[_?:],-)

Now I just need to figure out how to change an asterisk to [x]. The underscore tick changes them to a hyphen because MB changes them to an underscore before any of the scripting. Maybe someone out there will have a solution.

Thanx again for all the help…this forum is awesome!

I’ve been working on this myself for clarity and to better handle situations where the file doesn’t have any artist, say – and because I just find scripting fun. Sorry this only comes after you’ve spent the time yourself! And, no, I’m not sure how to handle the asterisks differently than default; I would suggest turning off “Windows compatibility”, but that’s a Unix special character. Anybody else have any input?

$noop(Strip slashes from various variables)
$set(_saveartist,$rreplace($left($if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%),25),/,-))
$set(_savealbum,$replace($left(%album%,40)$if(%date%,$if(%album%, )[$left(%date%,4)]),/,-))
$set(_savetitle,$replace($if(%album%,$left(%album%,30) - )$num(%discnumber%,1).$num(%tracknumber%,2)$if(%title%, - $left(%title%,30)),/,-))
$set(_cleanedartist,$replace(%artist%,/,-))
$set(_cleanedalbumartist,$replace(%albumartist%,/,-))

$replace(
$rreplace(
$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
	$noop("Various artists")
	%_saveartist%/
	%_savealbum%/
	%_cleanedalbumartist% - %_savetitle% [%_cleanedartist%]

	$noop(Unknown artists),$if($not(%_saveartist%),
	Unknown artist/
	%_savealbum%/
	%_savetitle%

	$noop(Everybody else),
	-= $upper($left(%_saveartist%,1)) =-/
	%_saveartist%/
	%_savealbum%/
	%_cleanedartist% - %_savetitle%
	))
,[_:],-)
,?,)

EDIT: Actually, the asterisks raise a question about the slashes: are they also replaced ahead of time to avoid unexpected folder creation? That would definitely make sense. Or is that what you were saying about the underscore?

2 Likes

I know you already found the following thread, just wanted to link to it for others:

4 Likes

I knew that sounded familiar, but I was forgetting exactly where I heard it. Thanks for the refresher!

So, @NightMyst, you’ll probably want to take the $replace calls out of the first five lines of my most recent script; whether you put the whole strings in a tagging script verbatim or just do so for the variables and leave the rest of the logic here is up to you.

Great! This looks like it helps clean up the code a lot. I’ll give it a try and see how it works. Besides, doing the work at the same time with you helps clarify stuff in my head. I read somewhere you could put a taggerscript in the Options…can you only hae one script?

1 Like

Sounds like you’ve fallen prey to a pretty common UI bug. You can definitely have more than one script, but the list of scripts apparently likes to hide itself. Mouse over the left border of the script editing box, and your mouse should turn into something indicating you can drag it. Do so, to the right.

1 Like

AH_HA! That’s solved! Thanx again.

Just a quick update…the final script seems to work like a charm. I haven’t solved the problem with changing asterisks to [x], but everything else works great.

However, when I try to rename the files and do the look-ups MB comes back with them as [non-album tracks] and saves them as noalbum, noartist. These wer all tagged by MB a couple of years ago and successfully matched the items. After manually tagging them with MB they work fine… I’m working on this problem now, but if anyone has any ideas I would appreciate their input. If I can’t find the answer I’ll start a new thread.

They might originally have only saved the recording ID for whatever reason; I have several standalone recordings in my library (or, rather, family mixtapes that aren’t notable enough to put on MB) and they act similarly once I remove the release, release group, and track IDs. By re-associating and resaving your files, you’re having Picard add those fields back in properly.

When you say noalbum and noartist, do you mean in the tags, or are those the default folders for the script? If it’s the latter, that’s more or less what I expect – I don’t think [non-album tracks] comes with release-level tags, though I’m not entirely sure why it’s not falling back on recording artist – but if it’s the former, my best guess is that you had a script adding those values a couple years ago, or a young Picard did so itself. Either way, the manual re-association is probably your best solution.

1 Like

I wish I could remember just how long ago I did these files. I’m thinking you may be right. I have been manually re-associating the files and , as a test, any subsequent look-up finds the right data. Other than that issue I haven’t found any other problem with the script as we finalized it. Thanx again!

I’ve been playing around with the script that Woven Tales posted.
I got it to how I like it, but I’d like to replace characters in the album folder. Yes this does this at the moment.

This is what I’d like it to do:
For AC/DC, it replaces it as AC-DC, which is great.
But if I have an album name of Gold: Greatest Hits, then it changes it to Gold- Greatest Hits, but I’d rather have it display as Gold - Greatest Hits.

This is the code I have so far. The only thing that I really changed was _savetitle line.

$noop(Strip slashes from various variables)
$set(_saveartist,$rreplace($left($if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%),25),/,-))
$set(_savealbum,$replace($left(%album%,40)$if(%date%,$if(%album%, )[$left(%date%,4)]),/,-))
$set(_savetitle,$replace($if(%album%,$left(%album%,30) - )$if($gt(%totaldiscs%,1),CD %discnumber%/,)$num(%tracknumber%,2)$if(%title%, - $left(%title%,30)),/,-))
$set(_cleanedartist,$replace(%artist%,/,-))
$set(_cleanedalbumartist,$replace(%albumartist%,/,-))

$replace(
$rreplace(
$if($eq(%musicbrainz_albumartistid%,89ad4ac3-39f7-470e-963a-56509c546377),
	$noop("Various artists")
	%_saveartist%/
	%_savealbum%/
	%_cleanedalbumartist% - %_savetitle% [%_cleanedartist%]

	$noop(Unknown artists),$if($not(%_saveartist%),
	Unknown artist/
	%_savealbum%/
	%_savetitle%

	$noop(Everybody else),
	%_saveartist%/
	%_savealbum%/
	%_cleanedartist% - %_savetitle%
	))
,[_:],-)
,?,)

So, @FragaGeddon, does it work? What would you like us to do?

I’m working on a new one. I’m kinda understand it a bit better now.
I’ll post it when I’m done.

Here’s what I came up with.

$noop( *** DO NOT EDIT THE AREA BELOW | EDITABLE AREA WILL BE AT THE VERY BOTTOM *** )
			$set(MainFolder1,-= $upper($left(%albumartist%,1)) =-/)
			$set(MainFolder2,-= $upper($left(%albumartistsort%,1)) =-/)
			$set(MainFolder3,)
			$set(Artist1,$replace($rreplace(%albumartist%,[_:*?"<>|],-),?,)/)
			$set(Artist2,$replace($rreplace(%albumartistsort%,[_:*?"<>|],-),?,)/)
			$set(Album1,$replace($rreplace(%album%,[_:*?"<>|], -),?,)$if(%date%,$if(%album%, )[$left(%date%,4)])/)
			$set(Album2,$replace($rreplace(%album%,[_:*?"<>|], -),?,)/)
			$set(MultiDisc1,$if($gt(%totaldiscs%,1),Disc $num(%discnumber%,1)/)
			$set(MultiDisc2,)
			$set(PreTitle1,$replace($rreplace(%albumartist% - %album% -,[_:*?"<>|], -),?,))
			$set(PreTitle2,)
			$set(Track1, $num(%tracknumber%,2) - )
			$set(Track2, $num(%discnumber%,1)-$num(%tracknumber%,2) - ))
			$set(Title,$replace($rreplace(%title%,[_:*?"<>|],),?,))
$noop( *** DO NOT EDIT THE AREA ABOVE| EDITABLE AREA IS JUST BELOW *** )




$noop( *** The Following will use the example of artist: Amy Winehouse and album: Back to Black *** )
$noop( *** Default output: -=A =-/Amy Winehouse/Back to Black [2007]/Disc 1/Amy Winehouse - Back to Black - 01 - Rehab *** )
$noop( *** Change the NUMERICAL value ONLY! Example: %MainFolder1% would be changed to %MainFolder2% *** )
$noop( *** Only change the numerical value to either 1 or 2, anything else will mess things up. *** )
%MainFolder1%	$noop( OPTION 1 -= A=- | OPTION 2 -= W =- | OPTION 3 = No single character folder will be created. )
%Artist1%			$noop( OPTION 1 = Amy WineHouse| OPTION 2 = Winehouse, Amy )
%Album1%			$noop( OPTION 1 = Back to Black [2007] | OPTION 2 = Back to Black )
%MultiDisc1%		$noop( OPTION 1 = If album has more than 1 Disc, then add Disc folders | OPTION 2 = Do not sort by Disc, put all files into a single folder. )
%PreTitle1%		$noop( OPTION 1 = Show Artist and Album in the track title | OPTION 2 = Do not display Artist or Album)
%Track1%			$noop( OPTION 1 = Track Number: 01 | OPTION 2: Track Number: 1-01-> This is best if MultiDisc is set to 2, because you will have 2 track numbers as 01 - *track names*, etc. )
%Title%				$noop( NO OPTION - Just display the name of the track. )

A post was split to a new topic: Syntax highlighting in Notepad++

Works Pretty good…but it places Soundtracks in S/Soundtrack/%album% [%date%]/and the selected title. and basically the same for Various Artists. Is there a way to save to /Soundtrack and /Various Artists WITHOUT putting them in the Alphabetized folder? Also, in the earlier script, the %artist% was added to the title in theses instances as such: %album% - $disc%.%track% - %title% [%artist%]…can this be accomplished here?

I made some minor adjustments, but forgot how to post code…duh

Guys, I need help…
My naming script is this:

$if2(%albumartist%,%artist%)/
$if(%albumartist%,%originalyear% - %album% - %catalognumber%/,)
$if($gt(%totaldiscs%,1),%discnumber%-,)$if($and(%albumartist%,%tracknumber%),$num(%tracknumber%,2) ,)$if(%_multiartist%,%artist% - ,)%title%

Now, when I have a track called:

Rienzi: Overture

The script names the file:

1-01 R.flac

Any ideas why, and/or how could I fix it?
Thanks.

… and you are sure the title isn’t “R”? Could you maybe add a link to the release you used for tagging?
The script looks largely like the one I’m using.