Hydrogenaudio Forums

Hosted Forums => foobar2000 => General - (fb2k) => Topic started by: loft on 2020-03-24 21:39:50

Title: Search and replace inside lyrics
Post by: loft on 2020-03-24 21:39:50
Hello,

Some time ago I've made a mistake when tagging my files and I've been dragging that mistake with me for such a long time that I even forgot what exactly the mistake was.

Basically in the case of some songs (probably many) I managed to insert at the beginning of the lyrics field (%lyrics%,%unsynced lyrics% of %unsyncedlyrics%, depending on the song) something like this:

Code: [Select]
');var c=function(){cf.showAsyncAd(opts)};if(window.cf)c();else{cf_async=!0;var r=document.createElement("script"),s=document.getElementsByTagName("script")[0];r.async=!0;r.src="//srv.tonefuse.com/showads/showad.js";r.readyState?r.onreadystatechange=function(){if("loaded"==r.readyState||"complete"==r.readyState)r.onreadystatechange=null,c()}:r.onload=c;s.parentNode.insertBefore(r,s)};}})();

I've been squeezing my brains out trying to devise some way to correct it, but I still cannot find something useful.

Basically the idea would be to search inside %lyrics%,%unsynced lyrics% of %unsyncedlyrics% fields for (); and then cut everything before this three caracters, including these 3 characters. I'm very confident that there aren't any songs containing this specific set of characters in their lyrics.

Any ideas?

Thanks!
Title: Re: Search and replace inside lyrics
Post by: Daeron on 2020-03-25 15:50:03
Library/Search:
Code: [Select]
%lyrics% HAS ();

Highlight all the files and create a new playlist with them. Double check there aren't many false positives.

Right-click on them and choose Properties. Tools > Automatically fill values.

Set Source to %lyrics%. Set Pattern to something like:
Code: [Select]
%% (); %lyrics%

This should net you the original column and the adjusted one to the right, with the unnecessary parts cut.

Double check this is what you want, then press OK and press Apply.

You could also write to %lyrics_test% or %temp% to the Pattern field (or whatever name you want to use) to see what the operation results in without touching your lyrics tags directly. You can delete the temporary tags later.

Repeat for unsynced lyrics.

Title: Re: Search and replace inside lyrics
Post by: loft on 2020-03-25 20:40:27
Hi Daeron,
Thanks for the suggestion!
Sadly it doesn't seem to work with multiline fields. Or at least, after half an hour of trying, that's what I believe. Could you please double-check my finding?

PS:I've read this (http://wiki.hydrogenaud.io/index.php?title=Foobar2000:Query_syntax#Guidelines) wiki article countless times.
Title: Re: Search and replace inside lyrics
Post by: Daeron on 2020-03-25 21:44:25
Interesting. The initial library search really doesn't seem to work, not even as something like:
Code: [Select]
"$strstr(%lyrics%,abc)" GREATER 0

So I guess you could just filter via this, which will simply return all tracks that contain lyrics:
Code: [Select]
%lyrics% PRESENT

Then you can run the same Pattern as in my original post. If everything works right it should still strip the problematic files and leave the regular ones untouched.

Make sure to do a couple test runs on some dummy files to check it actually does what you want.
Title: Re: Search and replace inside lyrics
Post by: loft on 2020-03-26 13:06:33
It simply refuses to search in multi row fields.
I'll have to investigate this.
Thanks for the help!
Title: Re: Search and replace inside lyrics
Post by: Just_Addict on 2020-03-26 14:55:35
It simply refuses to search in multi row fields.
I'll have to investigate this.
I may have a solution, as long as you can filter a playlist view to only contain tracks having lyrics, then the next step (searching in multiline text) can be done in MP3tag by selecting all of the tracks and then drag/drop them on a MP3tag window.
In MP3tag make sure the Filter is present at the bottom (View > Filter or F3) and just type in the same query Daeron provided.
To verify the remaining visible tracks have indeed this string at the beginning you can add the lyrics/unsyncedlyrics field(s) to the tag panel on the left and just check each file quickly by scrolling through them with arrow-down.

Once you're sure all of them match your requirement, select Actions > Actions (Quick) from the main menu and using the option "Replace with regular expression" should be able to do what you want (do try this on one file to be sure it works, you could even just take a file without lyrics and add that string to test with so you don't accidentally destroy an existing lyric). Also make sure to copy the regex first to a notepad or something as you'll need to repeat those steps once on all of the selected files after you verified it takes out what you need.

Also be aware that Foobar2000 calls the field %lyrics% but MP3Tag shows it as %unsyncedlyrics% in the Extended tag view
Title: Re: Search and replace inside lyrics
Post by: loft on 2020-03-26 20:38:05
Thanks guys! In the end I've got a bit of help here (https://hydrogenaud.io/index.php?topic=118996)and it worked! There were onyl 207 files corrupted.
Regarding the actual renaming, I used the Split function inside Masstagger with the whole unwanted text as the splitter (at least I was lucky that the unwanted text was the same in every file).
SimplePortal 1.0.0 RC1 © 2008-2020