View Full Version : Use regular expressions to guess tag formats?

2012-02-24, 03:04
Hi everyone

I've just started exploring the possibilities with Logitech Media Server to see if it will work well with my music collection. I'm very protective of it and it's good to see that LMS doesn't try and modify or move my music files around.

All my music is stored in A-Z folders by artist/compilation name and I'm very strict on file naming. As such I've never seen the need to use tags in my music files as I've always been able to easily find the songs I'm looking for. And keeping tags in sync with the file names was always a nightmare.

I have different formats for my file naming: Normal artist albums, mixed compilations (with track numbers), unmixed compilations (without track numbers), 1 off tracks under the A-Z directory.

As a result of not using tags (I must be the only person on the planet!) the music folder browsing method on squeezebox players can be quite clunky to use with large collections.
So I looked at the "Guess Tag Formats" setting in LMS preferences and that can almost get me there but it still guesses wrong in many scenarios.

Rather than using the "Guess Tag Formats" fields, is there a way to create regular expressions to provide powerful pattern-based custom mappings for the guessed tags?

Things like...

^[#A-Z]{1}\\(.+) - (.+)\\(\d+) - (.+)\.[a-z0-9]{3,4}$
With the bits in parentheses mapping to ARTIST - ALBUM\TRACKNO - TITLE in this case

^[#A-Z]{1}\\(.+) - (.+)\.[a-z0-9]{3,4}$
Parentheses being ARTIST - TITLE

^[#A-Z]{1}\\(.+)\\(.+) - (.+)\.[a-z0-9]{3,4}$


I'm guessing that regex mappings is a bit beyond what the developers of LMS thought would be needed by users. But if LMS is just a customised HTTP server I thought there must be some regex going on somewhere.

So it's a hopeful one but is there any way to use regex to guess the tag formats in LMS?

Cheers, B

2012-02-24, 03:22
If your file/folder names are as regularly set as you say, would it not be easier just to use one of the tagging tools to pull the meta data out of the file name and update the tags for all the files ?

If the data is regular enough for some regexes in LMS to handle it, then surely it should be in a decent state for one of the tagging tools to automatically update the tags ?

Life tends to be easier if you use tools the way their designers intended ;)

2012-02-24, 04:42
I don't see the point in using meta data to replicate data that's already contained in the file names.
Most of my music is single-file CD rips with the artists/title being identified in a cue sheet. Tagging the files would not be appropriate in this case.

It's a shame that LMS appears to be so reliant on file meta data as it looked like a reasonable solution. I was hoping to primarily use the browse folders method anyway.

I take it that you mean there's no way to use regex to help the guess tag formats setting get it right then?

Cheers, B

2012-02-24, 06:11
No built in way, no. But all the code is out there if you felt like adding the ability.

I imagine the scanner that reads the metadata and builds the database would be the place to start.