$rand() function?



First, thanks to the creators of mp3tag for such an excellent product. Goodbye Tag & Rename!

I have a question about the $rand() function. Is there a way to get it to return a random number within certain parameters? For example, I want to randomize the song order in a folder so i'd like to make an action to replace the track number with $rand($num_tracks) or something.

However $rand() does not appear to work like a typical rand() function... it just returns an integer > 0 with no upper limit, it seems. Usually in another language one would use something like int(rand($seed) * $upper_limit), but that's not an option here... or am I missing something? The help file doesn't want to tell me anything more.

Thanks again! :slight_smile:


As far as I know, you cannot set the boundaries for $rand().
If you want to randomize the track order in a folder and change the track numbers, click on the very first column (where the icons are) and then use the track numbering wizard [CTRL+K]. :slight_smile:


Cool, that is also good to know. I have a bigger idea for a script that could really use a $rand() with limits, but i can use that tip now. thanks Sebastian!


Try $num($left($rand(),2),2) as solution.
Do you also get the same numeres from the $rand() funktion?
41 18467 6334 26500 19169 15724...


that's a good idea, but still you could end up with track numbers higher than the total tracks in the album.

i suppose it's not a big deal... :smiley:


Following example returns random numbers from 0 to 10:

Following example returns random numbers from 1 to 11:

Following example returns random numbers from 5 to 15:

Following example returns random numbers from -5 to 5: