Please take a minute to check our Frequently Asked Questions. Use Search to reveal possible related topics.
Also make sure you've read the Forum Guidelines before posting in this forum.
![]() ![]() |
Sep 17 2006, 19:43
Post
#1
|
|
|
Member Group: Members Posts: 4 Joined: 17-September 06 Member No.: 3689 Mp3tag Version: 2.36a |
I've spent hours on this. :frustration: After I finally figured out that, for some un-Godly reason, %track% and %_total% return tracknumbers in different formats, I'm still running into problems. Basically, I want this loop to sort by album, and increment a counter variable everytime it finds a complete album, this telling me how many complete albums I have in any folder.
Here's my code (carriage returns are entered in for readability): CODE List compiled by %_app% Updated:'['COLOR="Blue"']'%_date%'['/COLOR']' $puts(no_albums,0) $loop(%album%) $if($eql($left(%track%,2),%_total%),$puts(no_albums,$add(1,$get(no_albums))),) $loopend() Added: '['COLOR="Blue"']''['SIZE="5"']'MUSIC'['/COLOR']' - '['COLOR="Red"']'$get(no_albums) Albums'['/COLOR']' and change For some reason, it outputs zero, even though when change $puts to $put it returns numbers other than zero. Even this is weird. I was testing it on an folder with 2 albums and a single track in it. The count it should have returned while looping was 1, 2. It returned 1, 2, 6. I have NO idea where that 6 is coming from, especially since no_albums can only be increased by one and that output occurs EVERYTIME that function is called. So, not only is the function being magically called a 3rd time, it's also being increased magically by 4. Can anyone help?!? Argghghg. |
|
|
|
Sep 17 2006, 21:02
Post
#2
|
|
![]() Moderator Group: Moderators Posts: 5503 Joined: 4-September 03 From: Germany Member No.: 201 Mp3tag Version: 2.55a |
CODE List compiled by %_app% Updated:'['COLOR="Blue"']'%_date%'['/COLOR']' $loop(%album%) $puts(no_albums,$if(%track%,$if($eql($num(%track%,2),$num(%_total%,2)),$add(1,$get(no_albums)),$get(no_albums)),$get(no_albums))) $loopend() and don't use $puts(no_albums,0) -------------------- |
|
|
|
Sep 18 2006, 00:49
Post
#3
|
|
|
Member Group: Members Posts: 4 Joined: 17-September 06 Member No.: 3689 Mp3tag Version: 2.36a |
CODE List compiled by %_app% Updated:'['COLOR="Blue"']'%_date%'['/COLOR']' $loop(%album%) $puts(no_albums,$if(%track%,$if($eql($num(%track%,2),$num(%_total%,2)),$add(1,$get(no_albums)),$get(no_albums)),$get(no_albums))) $loopend() and don't use $puts(no_albums,0) Thanks, that works, but . . . could someone perhaps explain to me why that code works and what I was using didn't? I mean, I mostly get why yours works. You make sure to update the variable everytime through the loop, either with a new value or the previous one. But that $if(%track%... statement confuses me. How does that make the distinction between a file that is part of an album and a file that isn't? The way that I have my media library set up it's probably not gonna matter, but in this case the program is sure execute that then statement for every single one of my 4100+ mp3s instead of saving some processing power by skipping over the ones that it knows are not part of an album. Mostly, I'm confused about why my code *doesn't* work . . . |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 20th May 2013 - 02:12 |