Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: QUERY SYNTAX | Search how many files within an Album (Read 1822 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

QUERY SYNTAX | Search how many files within an Album

Foobar2000 is my only music library of choice because of how flexible it is. I've been a user for several years now and still finding out ways to use it more effeciently. I've actually come across a devastating situation where a majority of my songs within my 8000+ track library has gotten track number set to "1". But, not all is bad as i'm able to retrieve the original tracklist from filename, but with some dilemma (e.g. of tracknumber set to 1):
Where left is saying for this Album all tracks are set to 1 and right shows filename with the original tracknumber

# EXAMPLE1 - %tracknumber% IS 1


Since I have a lot of songs within my library that only means a lot of Albums where there are correct track-no.1's and I'm trying to query a way to exclude seeing those files (here's what I came up with so far):
Where i'm searching up any song with a track-no. set to 1 and individually going through Albums where there's duplicate track#1's

# EXAMPLE2 - No. of tracks per %album%


The reason being that I can't select my whole library and retrieve the %tracknumber% via %filename% is because the file structure isn't consistent (like so):

# EXAMPLE3 - My library %filename% inconsistencies for mass tagging solutions


Now my question is, referring to EXAMPLE2, notice the numbering next to each Album? I want to add that to my query results to exclude any Album that only has an individual track#1. Instead, I want to only query results that have multiple track#1's within every Album in my library. Any ideas on how to do this?

Re: QUERY SYNTAX | Search how many files within an Album

Reply #1
What you want to query can't be queried by the built-in tools. But if the filenames are constructed the way your screenshots showed, you should get some results with this:
(tracknumber IS 1) AND ("$left(%filename%,2)" GREATER 01) OR ("$left(%filename%,3)" IS 01- AND "$substr(%filename%,4,5)" GREATER 01)

Re: QUERY SYNTAX | Search how many files within an Album

Reply #2
I tried that but it didn't seem to help much at all as it still listed many Albums with correct tracklisting. Something I did forget to mention is that there is about three different types of filename structures that I went through over the years. I would appreciate it if possible you could instead try and get Albums that has multiple tracks w/ multiple-track#1's  ???

Filename-Structure#1 01 foobar
Quote
%tracknumber% %title%

Filename-Structure#2 02-09 Foobar
Quote
%discnumber%-%tracknumber% %title%

Filename-Structure#3 01-01_01-04 Foo Bar
Quote
%discnumber%-%totaldiscs%_%tracknumber%-%totaltracks% %title%

I will say though that from my knowledge, this seemed to help
Code: [Select]
(tracknumber IS 1) AND ("$left(%filename%,3)" IS 01- AND "$substr(%filename%,4,5)" GREATER 01)

Re: QUERY SYNTAX | Search how many files within an Album

Reply #3
I understand you want to recover the track number from the file name. I wouldn't bother excluding actual number 1 tracks, because as long you retrieve the correct track number from every single file name, you can simply overwrite it.

I made a few tests on sample filenames based on the filename structures you posted, and this seems to work:
Code: [Select]
$puts(myvar,$trim($substr(%filename%,0,$strchr(%filename%, ))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),-),1),$len($get(myvar))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),_),1),$sub($strchr($get(myvar),-),1))),),)$get(myvar)


I'm late

Re: QUERY SYNTAX | Search how many files within an Album

Reply #4
I wouldn't bother excluding actual number 1 tracks, because as long you retrieve the correct track number from every single file name, you can simply overwrite it.

davideleo & Case thanks for chiming in. What started this was that I got this all-tracks-as-track01 error from VirtualDJ writing in tags and the program hang forcing me to restart it to a devastating outcome :( I still however need to do this per Album because some tracks were already MOVED/RENAMED with the track01-error (like so):



I made a few tests on sample filenames based on the filename structures you posted, and this seems to work:
Code: [Select]
$puts(myvar,$trim($substr(%filename%,0,$strchr(%filename%, ))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),-),1),$len($get(myvar))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),_),1),$sub($strchr($get(myvar),-),1))),),)$get(myvar)

I attempted this to no avail, any ideas? Of course i'm searching through my whole entire library, but to be sure I even used that Album from the image above [Blu - Good to be Home (2014)] and the results still show no results.



Re: QUERY SYNTAX | Search how many files within an Album

Reply #5
Code: [Select]
$puts(myvar,$trim($substr(%filename%,0,$strchr(%filename%, ))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),-),1),$len($get(myvar))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),_),1),$sub($strchr($get(myvar),-),1))),),)$get(myvar)

I attempted this to no avail, any ideas? Of course i'm searching through my whole entire library, but to be sure I even used that Album from the image above [Blu - Good to be Home (2014)] and the results still show no results.




Sorry, I guess I gave too much for granted. The titleformatting expression I posted is not a query. You can use it in the Automatically Fill Values dialog as the source string. It should give you the correct tracknumber for any of your files with either of the three filename structures you listed above. If it works, you can update the whole library with it, no need to do it on per album basis.
I'm late

 

Re: QUERY SYNTAX | Search how many files within an Album

Reply #6
(Use this Title-format-Referencing as a Automatically-Fill-Values and from the namingschemes (3-total) you've provided it will provide you with respective tracknumber via %filename% which you can then use to correct your %tracknumber% tag-error)

Code: [Select]
$puts(myvar,$trim($substr(%filename%,0,$strchr(%filename%, ))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),-),1),$len($get(myvar))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),_),1),$sub($strchr($get(myvar),-),1))),),)$get(myvar)

Genius! ;D This definitely helped a lot and it's proven effective. This is a reminder on how powerful Foobar2000 can be. I'm now able to replace all %tracknumber% via my filenamingscheme properly. 8)
Now,... I don't think i'm going off topic by hopefully being able to have a way to find all files within my library that isn't formatted in (see below), so that way I can overview all tracks that isn't imported with this filenamingscheme:
Code: [Select]
%discnumber%-%totaldiscs%_%tracknumber%-%totaltracks% %title%


Re: QUERY SYNTAX | Search how many files within an Album

Reply #7
Now,... I don't think i'm going off topic by hopefully being able to have a way to find all files within my library that isn't formatted in (see below), so that way I can overview all tracks that isn't imported with this filenamingscheme:
Code: [Select]
%discnumber%-%totaldiscs%_%tracknumber%-%totaltracks% %title%



Well, as far as I can see, compared to the other two, this naming structure is characterized by the underscore, therefore you could simply query for all files with an underscore:
Code: [Select]
%filename% HAS _

But because your filename structure 1 and 2 might also show an underscore in the %title% part, it would be safer to run the query against the numeric part of the filename only:
Code: [Select]
"$substr(%filename%,0,$strchr(%filename%, ))" HAS _

N.B.
As in my previous suggestion, I assumed the first occurrence of a blank space is always the one before the %title% part of the filename.
I'm late

Re: QUERY SYNTAX | Search how many files within an Album

Reply #8
Edit first: You don't have backup?


What I would have done in this situation:

* create a new folder for files with everything OK. Either outside the library or be prepared to filter it away from searches. Maybe an entire hard drive.
* create a move pattern that copies directory structure and filenames (no reason to introduce sources of error here!) and that moves the entire folder.
* move things that have tracknumber greater than 1 (again, take care to move the entire folder). Presumably, everything is OK with everything in those folders?

If you have a TOTALTRACKS or TRACKTOTAL tag, then you can move everything that has that tag equal to 1 as well.
And everything that is now left which got total number of tracks >1, will be surely wrong. Consider moving those to a different folder for "everything wrong". Then you got an idea of how much you need to tweak.

Edit:
And for later, I would have considered
* populating TOTALTRACKS. It possibly requires a hundred operations, but heck ...
* a filenaming format that is a bit more resilient to errors?  Now you can do that as part of the operation. For example, you can start searching for filenames that have DigitDigitWhitespace. When these have gotten a proper naming scheme, you can move them to an "everythingisOK" folder and exclude them from the search. Or you can in that naming scheme include a character that is NEVER used for anything else (how many "§" or "¶" or "¨" do you have?) and that can be excluded from searches; if you dislike that character, you can rename again when you have fixed everything.

And edit again:
Renaming is a bit risky in case you have backup with the same folder structure and same filename. Then you could end up making yourself unable to overwrite the same files.

Re: QUERY SYNTAX | Search how many files within an Album

Reply #9
[SOLVED]

Although I do have a backup it only lasts for a limited time and only noticed my issue after that period. So my backups had the errors aswell. I'm going to change this to prevent the problem of having all my track tag %TRACKNUMBER% changed to "1".

I had 2-methods to fix this issue of "all tracknumbers being 1."

1st option was fairly simple but tedious because it meant manually identifying which albums had multiple tracks after querying `%tracknumber% IS 1` via Foobar2000's built-in Library viewer (query was a little extra to suit my personal need):
https://postimg.cc/image/49lffeqmz/.

2nd option was efficient as I knew I had only 3-filenamingstructures of which only 2 provided total tracks (so using the option#1 helped with the filenamingstructure that didn't provide %TOTALTRACKS%): `$puts(myvar,$trim($substr(%filename%,0,$strchr(%filename%, ))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),-),1),$len($get(myvar))))$ifgreater($strchr($get(myvar),-),0,$puts(myvar,$substr($get(myvar),$add($strchr($get(myvar),_),1),$sub($strchr($get(myvar),-),1))),),)$get(myvar)`

A brief recap of both options is one is manual (but not that bad if you have some time, drink coffee and go down the list) and the other used a Title-format-Referencing as a Automatically-Fill-Values. I guess the only way to know what I mean is to try out my 2nd option and really understand Foobar2000's terminology to be a library soldier. Thanks to all those who helped me from davideleo for his amazing code input aswell as case for chiming in and Porcus for emphasizing library backups for which a lot of people do differently. My backup is harddrive copy to another so I can see the different increments from time to time without any RAID-arrays. Just remember that I would suggest doing filenaming by the couple of albums (let's say for ever 100 files at a time) to prevent any further mishaps.

What I lacked was not having a full-fledged backup mechanism that wouldn't made me detect the problem sooner!