Author Topic: Help with a search & replace tool  (Read 1315 times)

chrswrn

  • Guest
I need help with creating a search & replace command. It's very specific to me and the way I organise my library, but if somebody can spare the time to help me out I'd be so grateful!

It might require RegEx (i'm not sure) I just know that I've tried various things without success so far.

What I'd like is to create a search & replace function that will automatically change tracks as per below example:

orginal
Title: Dopeness
Artist: The Black Eyed Peas, CL

after running command
Title: Dopeness [ft. CL]
Artist: The Black Eyed Peas

What would be even better is - in the case of more than one featured artist - it also replaced the last comma within the square brackets with a space and ampersand, to behave like this:

orginal
Title: Ice Behind My Lip
Artist: Riff Raff, CHXPO, Trapboy Freddy, Yowda

after running command
Title: Ice Behind My Lip [ft. CHXPO, Trapboy Freddy & Yowda]
Artist: Riff Raff
Last Edit: November 10, 2018, 08:41:10 PM by chrswrn

redwing

  • Guest
Do you really want to remove all guest artist from artist tag? Then you won't be able to find those tracks via their artist tag.

redwing

  • Guest
For title, create a virtual tag with the following code and copy the tag to title tag using Additional Tagging Tools plugin.

Code
<Title>$If($First(<Artist>)=<Artists>,," [ft. "$If($Split(<Artists>,;,2)=$RSplit(<Artists>,;,1),$RSplit(<Artists>,;,1),$Replace($RxReplace(<Artists>,"^[^;]+;\s*(.*);\s*([^;]+)$","$1 & $2"),;,","))"]")

To remove all artists except first artist from artist tag, copy the following virtual tag to artist tag.

Code
$First(<Artist>)
Last Edit: November 11, 2018, 07:20:47 PM by redwing

chrswrn

  • Guest
Do you really want to remove all guest artist from artist tag? Then you won't be able to find those tracks via their artist tag.

Yes.
To explain, I plan to use this when adding new tracks to my library, not to update existing files. I'd like help creating a Preset in the Advanced search and replace plugin that will instantly do what I've outlined in the OP, so I can quickly update new tracks when I add them.
I'm aware MusicBee can do so much more with artists/featured artists/split artists etc, and ultimately, I do have plans to tidy up all of my tracks with a featured artist and make used of what MusicBee can do, but I've only recently made the switch from iTunes and I have a whole ton of tracks set in this way at the moment, so for now am continuing with it.

Thanks for your help, but it hasn't worked. I'm not sure if there's something wrong with the code you've given or if I've not followed your instructions properly? Here's what I did:

1) Went to Edit Preferences -> Tags (1) -> Define New Tags...
2) Created a virtual tag with label Featured Artist(s) and formula <Title>$If(<Artist>=<Artists>,," [ft. "$If($Split(<Artists>,;,2)=$RSplit(<Artists>,;,1),$RSplit(<Artists>,;,1),$Replace($RxReplace(<Artists>,"^[^;]+;\s*(.*);\s*([^;]+)$","$1 & $2"),;,","))"]")
3) Put an album in my inbox that had featured artists in the Artist tag in the way I said in OP
4) Right-clicked one of those tracks, went to Additional Tagging Tools -> Copy tag...
5) Copied the new virtual tag to title and clicked Preview. But no changes were made:

Last Edit: November 11, 2018, 07:02:08 PM by chrswrn

redwing

  • Guest
If you add the virtual tag to the main panel as a column, does it show the expected value?

redwing

  • Guest
OK. I can see what's going on. How do you tag multiple artists?
Do you just put "Riff Raff, CHXPO, Trapboy Freddy, Yowda" in artist tag box?

redwing

  • Guest
In that case, using MB's native search & replace command, replace "," in artist tag with ";" first.
That will split them to individual artist tag. And then see if the virtual tag works.

chrswrn

  • Guest
OK. I can see what's going on. How do you tag multiple artists?
Do you just put "Riff Raff, CHXPO, Trapboy Freddy, Yowda" in artist tag box?

Ah I see the confusion. It's not me that's tagged it like that. But that is quite a common format of the Artist tag when I download an album or import a cd. I then usually tidy up some tags from the Inbox tab before adding them to my library (usually i will add artwork, use the Change Case function if necessary, and then spend time manually editing the featured artists when they're in the Artist tag rather than the title.) It's the last part of that process I'd like to speed up by assigning a hotkey to a preset, to automatically do the otherwise manual task.

Hope it all makes sense.

In that case, using MB's native search & replace command, replace "," in artist tag with ";" first.
That will split them to individual artist tag. And then see if the virtual tag works.

That still hasn't worked as you can see here:


redwing

  • Guest

chrswrn

  • Guest
I have updated the code. Can you try with it?

Yes, that's worked! Thanks for your help redwing, much appreciated :-)

redwing

  • Guest
You can create a custom preset using "TOY: Copy tags" preset. Make a copy of it, give it a new name, and change its source and target tag and save it. Then you can assign a hotkey to that preset.