Author Topic: Search and replace - Lyrics  (Read 1845 times)

Tybot

  • Sr. Member
  • ****
  • Posts: 336
I'm looking to clean up my embedded lyrics by removing special characters from the end of each line, mainly periods, commas, question marks, and so on. I'm able to find the files in question using the custom search but the lyrics tag does not appear to be available in the search and replace tool.

Any ideas on how to accomplish this? Third party tools?

phred

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 9356
You can search Lyrics with MB's 'custom search' tool. Find the lyrics in question and create a playlist for them. And work from there.

It's also possible to make it more automated with the Additional Tagging and Reporting Tools plug-in. It can certainly do a search and replace. I don't think there's a preset for exactly what you want but you could create one.
Download the latest MusicBee v3.5 or 3.6 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
The FAQ
The Wiki
Posting screenshots is here
Searching the forum with Google is  here

Tybot

  • Sr. Member
  • ****
  • Posts: 336
Yes, I messed around a bit with ATRT and got somewhat closer. However, it seems like the lyrics are stored as one long string with no indication of where the line breaks are. If the last line of the lyric ended in one of the characters I mentioned, ATRT was able to replace that character the way I wanted it to. But I'm still unsure of if/how to get the command working recursively and just at the end of the lines.

The Incredible Boom Boom

  • Sr. Member
  • ****
  • Posts: 1281
Yes, I messed around a bit with ATRT and got somewhat closer. However, it seems like the lyrics are stored as one long string with no indication of where the line breaks are. If the last line of the lyric ended in one of the characters I mentioned, ATRT was able to replace that character the way I wanted it to. But I'm still unsure of if/how to get the command working recursively and just at the end of the lines.

I presume the tags are embedded in the music file?
I would personally use MP3TAG, but since you're got it somewhat working with the Additional Tagging & Tools plugin, paste an example of what you're attempting to match/replace and your regexp.

Tybot

  • Sr. Member
  • ****
  • Posts: 336
Yes, I messed around a bit with ATRT and got somewhat closer. However, it seems like the lyrics are stored as one long string with no indication of where the line breaks are. If the last line of the lyric ended in one of the characters I mentioned, ATRT was able to replace that character the way I wanted it to. But I'm still unsure of if/how to get the command working recursively and just at the end of the lines.

I presume the tags are embedded in the music file?
I would personally use MP3TAG, but since you're got it somewhat working with the Additional Tagging & Tools plugin, paste an example of what you're attempting to match/replace and your regexp.

Yes, every track has embedded lyrics.

I was in the middle of something else so I only spent about five minutes on it and it's not very intricate.

Tag: Lyrics
Search for: [.,;:?]*$
Replace with: This field is empty

Is there any upside to using mp3tag instead? I prefer not to run a lot of files through it after they've been added to and edited in musicbee as it seems to mess with my artist sorting for some reason. I have a way around that, but still.

The Incredible Boom Boom

  • Sr. Member
  • ****
  • Posts: 1281
Tag: Lyrics
Search for: [.,;:?]*$
Replace with: This field is empty

So... you're trying to replace each of those punctuation characters... or just commas, semi-colons and colons?
You're only having the last match replaced, because you're not escaping the question mark.

Quote
Is there any upside to using mp3tag instead?

The interface is less of a hassle and you can preview the Format Value results.

hiccup

  • Sr. Member
  • ****
  • Posts: 7893
However, it seems like the lyrics are stored as one long string with no indication of where the line breaks are.
Are you testing this on mp3 and/or on flac?
If mp3, ID2.3 or 2.4?
I vaguely recall there was something special about how mp3 stores lyrics.
But I may be completely mistaken about this.

Tybot

  • Sr. Member
  • ****
  • Posts: 336
Tag: Lyrics
Search for: [.,;:?]*$
Replace with: This field is empty

So... you're trying to replace each of those punctuation characters... or just commas, semi-colons and colons?
You're only having the last match replaced, because you're not escaping the question mark.

I'm trying to replace all the punctuation marks inside the brackets if they're present at the end of a line, question marks included and I've also added exclamation points. I would like to keep punctuation marks that exists inside sentences. I just tried escaping the question mark but it still only replaces the match found on the last line of the lyrics.

Basically, I'm looking to turn this:

Quote

It ain't easy!
Living like a gypsy.
Tell your honey how I feel?
I've been dreaming...
Floating! Down the stream and,
Losing touch with all that's real
Whole earth lover. Keeping under cover


Into this:


Quote

It ain't easy
Living like a gypsy
Tell your honey how I feel
I've been dreaming
Floating! Down the stream and
Losing touch, with all that's real
Whole earth lover. Keeping under cover


Are you testing this on mp3 and/or on flac?
If mp3, ID2.3 or 2.4?
I vaguely recall there was something special about how mp3 stores lyrics.
But I may be completely mistaken about this.

It's all flac currently so whatever I come up with only has to work on vorbis comment.

The Incredible Boom Boom

  • Sr. Member
  • ****
  • Posts: 1281
Tag: Lyrics
Search for: [.,;:?]*$
Replace with: This field is empty

So... you're trying to replace each of those punctuation characters... or just commas, semi-colons and colons?
You're only having the last match replaced, because you're not escaping the question mark.

I'm trying to replace all the punctuation marks inside the brackets if they're present at the end of a line, question marks included and I've also added exclamation points. I would like to keep punctuation marks that exists inside sentences. I just tried escaping the question mark but it still only replaces the match found on the last line of the lyrics.

In a proper interpreter, it should work as you want, provided the characters are escaped and the line breaks are correct. Along with not knowing exactly which flags @Steven has made default for regexps, @boroda might've also disabled or enabled different ones for his plug-in, as well. It's hard to say what's going wrong.

Code
[\!\.\:\;\?\,]*$

Try opening a track in MP3TAG and executing the code with the 'Replace with regular expression' tool.

Tybot

  • Sr. Member
  • ****
  • Posts: 336

In a proper interpreter, it should work as you want, provided the characters are escaped and the line breaks are correct. Along with not knowing exactly which flags @Steven has made default for regexps, @boroda might've also disabled or enabled different ones for his plug-in, as well. It's hard to say what's going wrong.

Code
[\!\.\:\;\?\,]*$

Try opening a track in MP3TAG and executing the code with the 'Replace with regular expression' tool.

Worked like an absolute charm. Thank you very much! :D

Going to start small and then it's on to doing about 15k tracks
Last Edit: March 05, 2021, 03:45:29 AM by Tybot