Skip to main content
Topic: Trying To Use Folder Structure To Add Source/Media Type Column (Read 587 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Trying To Use Folder Structure To Add Source/Media Type Column

So my music is organized into folders like

CDs
Vinyl
SACDs

and more

And I want a way to easily see where a certain album is from, especially since I have more than a few albums with multiple versions (whether multiple vinyl pressings, or one vinyl pressing and one CD, with identical tracks, a way to differentiate them)

So I ended up trying to write a code for Foobar2000 using a large if statement, checking what the directory 2 levels up
Code: [Select]
$directory(%path%,2)
was called for songs/albums, and displaying it in it's own column

So like for example it would check if a folder for a CD is in the "CDs" folder (which it should be), and in it's own column, put "CDs", based on the directory structure and stuff

But I quickly realized if for instance certain music files were not exactly 2 levels or whatever (like a collection, with multiple folders for multiple albums), that it wouldn't work properly.

I am stuck here
Code: [Select]
$if($stricmp($directory(%path%,2),Reels),Reel,$if($stricmp($directory(%path%,2),Vinyl),Vinyl,$if($stricmp($directory(%path%,2),SACDs),SACD,$if($or($stricmp($directory(%path%,2),WEB),$stricmp($directory(%path%,3),WEB)),WEB))))

The last thing I ended up adding was two different checks for WEB releases, that were at different levels (2 and 3), and I thought that would work for all of my WEB releases, but apparently not, and thought it would be impractical to add yet another check for WEB releases at another different level (4?)
This same problem applies to some other types of music I have, mentioned earlier, such as vinyl, like for some that are packs of vinyl by a certain artist

There has got to be a better way to do this.
I tried to just check for each format in %path% with $strcomp or $stricomp, in order to sort that way, but I couldn't get it to work

I'm really sorry if this is an unintelligible mess of confusion, I have been working on this for too long and just want to get it done

Thanks so much to anyone that might be able to help

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #1
So my music is organized into folders like

CDs
Vinyl
SACDs

and more

And I want a way to easily see where a certain album is from, especially since I have more than a few albums with multiple versions (whether multiple vinyl pressings, or one vinyl pressing and one CD, with identical tracks, a way to differentiate them)

So I ended up trying to write a code for Foobar2000 using a large if statement, checking what the directory 2 levels up
Code: [Select]
$directory(%path%,2)
was called for songs/albums, and displaying it in it's own column

So like for example it would check if a folder for a CD is in the "CDs" folder (which it should be), and in it's own column, put "CDs", based on the directory structure and stuff

But I quickly realized if for instance certain music files were not exactly 2 levels or whatever (like a collection, with multiple folders for multiple albums), that it wouldn't work properly.

I am stuck here
Code: [Select]
$if($stricmp($directory(%path%,2),Reels),Reel,$if($stricmp($directory(%path%,2),Vinyl),Vinyl,$if($stricmp($directory(%path%,2),SACDs),SACD,$if($or($stricmp($directory(%path%,2),WEB),$stricmp($directory(%path%,3),WEB)),WEB))))

The last thing I ended up adding was two different checks for WEB releases, that were at different levels (2 and 3), and I thought that would work for all of my WEB releases, but apparently not, and thought it would be impractical to add yet another check for WEB releases at another different level (4?)
This same problem applies to some other types of music I have, mentioned earlier, such as vinyl, like for some that are packs of vinyl by a certain artist

There has got to be a better way to do this.
I tried to just check for each format in %path% with $strcomp or $stricomp, in order to sort that way, but I couldn't get it to work

I'm really sorry if this is an unintelligible mess of confusion, I have been working on this for too long and just want to get it done

Thanks so much to anyone that might be able to help

Update: After attempting to find another way to do this, I wrote this:
Code: [Select]
$if($strstr(%path%,Blu-Ray Audio),Blu-Ray Audio,$if($strstr(%path%,Cassettes),Cassette,$if($strstr(%path%,Declip),Declip,$if($strstr(%path%,CDs),CD,$if($strstr(%path%,DAT),DAT,$if($strstr(%path%,DVD-A),DVD-A,$if($strstr(%path%,HDtracks),HDtracks,$if($strstr(%path%,HIGHRESAUDIO),HIGHRESAUDIO,$if($strstr(%path%,Pono),Pono,$if($strstr(%path%,Reels),Reel,$if($strstr(%path%,SACDs),SACD, )))))))))))

which is a bit incomplete in including all the formats I have (SACD is not the last one), but the problem I'm having now, is that there is conflicts when searching for CDs, because CDs is part of the name SACDs. Putting either one in quotes or both (I just tried everything) didn't work to basically just separate them.

I feel like other than this issue, this method of using the
Code: [Select]
$if($strstr
compared to the flawed folder structure method I was using before is a lot better overall. If anyone knows how to fix that CDs/SACDs conflict, or just generally improve upon it somehow, I would greatly appreciate it.

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #2
Could you use something like this?
Code: [Select]
$puts(p,$replace(%path%,G:\Music\,,\\nas\share\Music\,))
$left($get(p),$sub($strstr($get(p),\),1))
Add the locations you store your music at to the replace line and just take the first part of the leftover path.

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #3
Could you use something like this?
Code: [Select]
$puts(p,$replace(%path%,G:\Music\,,\\nas\share\Music\,))
$left($get(p),$sub($strstr($get(p),\),1))
Add the locations you store your music at to the replace line and just take the first part of the leftover path.

Wow, that works almost perfectly! Thank you so much!
One question though, how can I easily make it so that the format folders that are plural appear as singular? (example: CDs > CD)

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #4
Could you use something like this?
Code: [Select]
$puts(p,$replace(%path%,G:\Music\,,\\nas\share\Music\,))
$left($get(p),$sub($strstr($get(p),\),1))
Add the locations you store your music at to the replace line and just take the first part of the leftover path.

Wow, that works almost perfectly! Thank you so much!
One question though, how can I easily make it so that the format folders that are plural appear as singular? (example: CDs > CD)

Actually, having a little bit of a problem with a subfolder of my main music folder, which is all stuff from a specific site and has it's own dedicated things like CDs, Vinyl, etc. separate from the other CDs, Vinyl, etc. one level above. For anything in that site folder, even though it's organized into format subfolders in there too, it just shows as the name of the site folder and not the format subfolder (for that release).

Hope this makes even the littlest bit of sense, and I appreciate all the help so far.

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #5
I might be oversimplifying this, but can you not just use the 'mediatype' tag field? You can then batch tag your CD folder for example with 'CD' or whatever text you require in the mediatype field and add the tag to show in Foobar to sort them by?

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #6
I might be oversimplifying this, but can you not just use the 'mediatype' tag field? You can then batch tag your CD folder for example with 'CD' or whatever text you require in the mediatype field and add the tag to show in Foobar to sort them by?

It's not a bad idea, and I was going to include that I tried to do something like that before, but I have a lot of music and I am just trying to make it so I don't have to tag all of it (which would take a very long time) and new stuff too. Thanks for the suggestion though.

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #7
If you already have your music ordered into main folders as you described, tagging your files accordingly should be trivial. The sooner you start tagging your stuff the less pain you will face in the future trying to maintain your library.

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #8
If you already have your music ordered into main folders as you described, tagging your files accordingly should be trivial. The sooner you start tagging your stuff the less pain you will face in the future trying to maintain your library.

I'm confused what you mean as you described tagging in my case as trivial, but then the second thing you said sounds like you recommend I do it? I'm not entirely against tagging everything, but it would take a while and this current method may not be bad for now (it is simpler to do it without tagging everything for some things that are harder to tag like SACD and DVD-A ISOs).

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #9
I meant trivial in the sense that it's simple to do, "not special". Perhaps not the best usage of the word there.

You could use a library viewer that allows you to browse by file structure or use a search query like:
Code: [Select]
%path% HAS D:\PathToMusic\Type\

Then tag the returned tracks accordingly. But if you have formats that don't support tagging then that does make it more complicated, something that I didn't take into account.

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #10
Could you just include a backslash for CDs?

Code: [Select]
$if($strstr(%path%,\CDs),CD ...)

Incidentally, MEDIA is the suggested tag to use according to here, if you are going that way.

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #11
Could you use something like this?
Code: [Select]
$puts(p,$replace(%path%,G:\Music\,,\\nas\share\Music\,))
$left($get(p),$sub($strstr($get(p),\),1))
Add the locations you store your music at to the replace line and just take the first part of the leftover path.

I appreciate all the helpful suggestions, but the one above is still what has worked best for what I want to do, minus the fact that some stuff from a specific source I have (not source as in media, but a site) is sorted/shown by that in Foobar2000, rather than the media type:

Like I have for example in my regular Music folder:

CDs
Vinyl
SACDs
RED (the site)

and within that RED folder,
it also has folders like

CDs
Vinyl
SACDs

but stuff in those folders show as RED, rather than CDs or Vinyl in Foobar2000.

Other than that, the solution works best for me right now.

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #12
Perhaps you can add that folder to the $replace ? (first position)

Code: [Select]
$puts(p,$replace(%path%,G:\Music\RED\,,G:\Music\,,\\nas\share\Music\,))
$left($get(p),$sub($strstr($get(p),\),1))

(correcting drive letters)

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #13
Perhaps you can add that folder to the $replace ? (first position)

Code: [Select]
$puts(p,$replace(%path%,G:\Music\RED\,,G:\Music\,,\\nas\share\Music\,))
$left($get(p),$sub($strstr($get(p),\),1))

(correcting drive letters)

I should have thought of that! Thank you so much, it seems to have worked perfectly. The only small thing which I would be perfectly ok with keeping if it's too much of a hassle, is that instead of showing CDs (for instance, or SACDs, Cassettes), instead show the singular form of whichever folder something is in (CD, SACD, Cassette). I still absolutely appreciate the actual solution to the original problem so much (to all that helped), so if this too much to ask, I understand.
(Edit: Except for HDtracks? Because HDtrack wouldn't really be correct, not sure how one could only apply it to CDs, SACDs, Cassettes, etc.)

Re: Trying To Use Folder Structure To Add Source/Media Type Column

Reply #14
Perhaps you can add that folder to the $replace ? (first position)

Code: [Select]
$puts(p,$replace(%path%,G:\Music\RED\,,G:\Music\,,\\nas\share\Music\,))
$left($get(p),$sub($strstr($get(p),\),1))

(correcting drive letters)

I should have thought of that! Thank you so much, it seems to have worked perfectly. The only small thing which I would be perfectly ok with keeping if it's too much of a hassle, is that instead of showing CDs (for instance, or SACDs, Cassettes), instead show the singular form of whichever folder something is in (CD, SACD, Cassette). I still absolutely appreciate the actual solution to the original problem so much (to all that helped), so if this too much to ask, I understand.
(Edit: Except for HDtracks? Because HDtrack wouldn't really be correct, not sure how one could only apply it to CDs, SACDs, Cassettes, etc.)

I seem to have solved the plural issue with this

Code: [Select]
$replace($puts(p,$replace(%path%,E:\Music\RED\,,E:\Music\,,H:\Music\,))
$left($get(p),$sub($strstr($get(p),\),1)),Cassettes,Cassette,CDs,CD,Premasters,Premaster,Reels,Reel)

(like my initial post, how searching text for 'CDs' obviously got both CDs and SACDs, this new solution also suffers from that problem, but it seems to work out since it basically just takes the s off the end for both).

Once again, this is most definitely a bad way to do this and makes the code not future-proof without having to go in and add it (which isn't a big deal, but I feel it's possibly something that could be avoided if there is an alternative method to this), if that makes a single bit of sense, but it works for me, so unless someone far more skilled than me knows of a better way to do it, then I'll just keep this for now I guess. Thanks again to those who replied with the main solution to getting the folder names.

 
SimplePortal 1.0.0 RC1 © 2008-2020