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: Columns UI: guessing tracknumber from filename (Read 2844 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Columns UI: guessing tracknumber from filename

I made a script that guesses the tracknumber from the filename of the track, if theres no tracknumber info in the meta tag. I don't believe its that effecient, but it works.
I use foobar 0.9.5.3 with columnsui

All my albums are tagged 01-artist-song for single albums and 101-artist-song, 102, 103 etc for multidisc albums. Now what my code does: it gets the first 3 characters from the filename. If its 01- it will delete the -

Thats easy.
For multicd it echos 101 ; 102 ; etc. Then i let it subtrack 100, so 104 will become 4 (to which an 0 will be added in the end). When it has stripped it, it checks again if its still > 100 ... so 204 will become 104, will become 4. I worked it out so that it works up to a 6CD album.

Now every multicd is labeled like this:
CD1:
01
02
03
04
etc.
CD2:
01
02
03
etc.

but what i would like it to do, is to keep counting from where it stopped in the previous cd. So:
CD1:
01
02
03
CD2
04
05
06
CD3
07
08

So really i need a way for my code to know how much tracks are present on the previous cd...
i cant figure it out, who of you more experienced guys can help me out?

Tnx in advance
[hope this is in the right thread]

Here's the code:

Code: [Select]
// START TRACKNR-GUESS

// get first 3 characters of the filename
$puts(raw_track,$padcut(%filename%,3))

// delete the - or _ sign if its there
$puts(raw_track,$replace($get(raw_track),-,))
$puts(raw_track,$replace($get(raw_track),_,))

// store the tracknumber minus x
$puts(raw_min_100,$sub($get(raw_track),100))
$puts(raw_min_200,$sub($get(raw_min_100),100))
$puts(raw_min_300,$sub($get(raw_min_200),100))
$puts(raw_min_400,$sub($get(raw_min_300),100))
$puts(raw_min_500,$sub($get(raw_min_400),100))
$puts(raw_min_600,$sub($get(raw_min_500),100))

// if track_raw is greater than 100 go on, else keep it
$puts(check_1,$ifgreater($get(raw_track),100,
$get(raw_min_100),$get(raw_track)))

$puts(check_2,$ifgreater($get(check_1),100,$get(raw_min_200),$get(raw_min_100)))

$puts(check_3,$ifgreater($get(check_2),100,$get(raw_min_300),$get(raw_min_200)))

$puts(check_4,$ifgreater($get(check_3),100,$get(raw_min_400),$get(raw_min_300)))

$puts(check_5,$ifgreater($get(check_4),100,$get(raw_min_500),$get(raw_min_400)))

$puts(check_6,$ifgreater($get(check_5),100,$get(raw_min_600),$get(raw_min_500)))

// check at each check if the number is greater than 100
$puts(tracknr_raw,
$ifgreater($get(check_1),100,

$ifgreater($get(check_2),100,

$ifgreater($get(check_3),100,

$ifgreater($get(check_4),100,

$ifgreater($get(check_5),100,
$get(check_6),

$get(check_5)),
$get(check_4)),
$get(check_3)),
$get(check_2)),
$get(check_1)))

// get the guessed tracknumber if there isnt one in the meta tag
// also, add a 0 to it, and if its then like 001, remove the 0 again

$set_global(tracknr,$if(%tracknumber%,%tracknumber%,
$ifgreater($get(tracknr_raw),9,$get(tracknr_raw),
$replace(0$get(tracknr_raw),00,0)
)
)
)
$puts(tracknr,$get_global(tracknr))
// END TRACKNR-GUESS

Columns UI: guessing tracknumber from filename

Reply #1
well, 1st of all, if you files are named correctly why can't you use tagging scripts?

you can't do what you want unless you are using < F2K 0.9.5. and cwb_hooks, which can get info about previous track, and of course even more power to it with custom_info, so don't bother.

you can try to look in lyx (azrael, navigator, olight...) scripts for guessing, they are interesting but they consume more processor time, so here is simple fast code for 2 number guessing (supposing that track # is in the begining of the file):

Code: [Select]
// Begin

$if($meta_test(tracknumber),$puts(track,$num(%tracknumber%,2)),

$puts(lr,$if3($strchr(%filename%,0),$strchr(%filename%,1),$strchr(%filename%,2),$strchr(%filename%,3),$strchr(%filename%,4),$strchr(%filename%,5),$strchr(%filename%,6),$strchr(%filename%,7),$strchr(%filename%,8),$strchr(%filename%,9)))

$puts(rl,$if3($strchr(%filename%,9),$strchr(%filename%,8),$strchr(%filename%,7),$strchr(%filename%,6),$strchr(%filename%,5),$strchr(%filename%,4),$strchr(%filename%,3),$strchr(%filename%,2),$strchr(%filename%,1),$strchr(%filename%,0)))

$if($strcmp($sub($get(rl),$get(lr)),0),$puts(rl,$add($get(rl),1)))

$if($greater($get(rl),$get(lr)),
$puts(track,$num($substr(%filename%,$get(lr),$get(rl)),2)),
$puts(track,$num($substr(%filename%,$get(rl),$get(lr)),2)))
)

// End

Columns UI: guessing tracknumber from filename

Reply #2
all my files are sfv corret now, and i don't want to change them, thats why i cant adjust the meta-tags... gonna try you're simple guessing code now.

Your code works for tracks that start with 01, 02, 03 etc.. but not with 101, 102, 103, 104, 201, 202, 203 etc..

Columns UI: guessing tracknumber from filename

Reply #3
as i said with f2k > 0.9.5. you task is impossible, and the code that i send is just a simple example of fast 2 # guessing code, which is unusible for your track namings (but for common names works just fine and is fast).

the var at the begining [tracknr] i parse at the end of my globals, but in the example there should be [track] instead of [tracknr] to avoid confusion even in this simple code - but you probably figure that one (i'll correct them now)

you need at least info about prev. track which you can't reach even with some temp global vars (with cwb_hooks you can get them, but there is no point of going back to some prev. versions of f2k)

so your only info is %list_index% and that's not enough.

keep in touch with your progression.

btw, what's sfv?

Columns UI: guessing tracknumber from filename

Reply #4
Simple file verification (SFV) is a file format for storing CRC32 checksums of files in order to verify the integrity of files. SFV can be used to detect random corruptions in a file, but cannot be used for checking authenticity in any meaningful way. Typically, the .sfv extension is used on SFV files.

Its a way to see that the files that you own are still in their original state...

And yeah, you're code is good voor your kind of tags... mine works too, it just echoes the first 2 characters of the filename ...

anyway i guess we'll have to hope from the developers that they include something to see previous track info or something

Columns UI: guessing tracknumber from filename

Reply #5
i knew that FV is for file verification, but i was gessing about S (simple
CRC (or maybe better MD5)

and i think that waiting for prev/next info will be endless, according to f2k developers, but who knows?

i tried your code the first time and it didn't work for me, so i thought it's just a part of your script.
you aren't yoking, are you?