Make a Random Toast CD

This is a silly applescript that does one thing: picks random songs out of your mp3 collection and sends them to toast to make a new CD for you. I wrote it one day when I was going out on the road and wanted to listen to some of my mp3s...then I got lazy, and wrote this script afterwards, Enjoy!


mount volume "mp3 collection" on server "test_server" as user name "my_user" with password "my_password"
set myFiles to (list folder "mp3 collection:" without invisibles)
set totalFiles to the number of items in myFiles
set howManyRandoms to 30
set bootVol to (the first item of (list disks))
set randomFile to bootVol & ":random.txt"

-- pull the random number seed from the entropy server
set myURL to "http://www.random.org/cgi-bin/randnum?num=1&max=1000"
tell application "URL Access Scripting"
download myURL to file randomFile replacing yes
end tell

set fileRef to (open for access file randomFile)
set myInt to read fileRef as string
close access fileRef
tell application "Finder"
delete file randomFile
end tell
set
myNum to (characters 1 through ((length of myInt) - 1) of myInt) as string
set mySeed to myNum as integer

set fileList to {}

set onePick to (random number from 1 to totalFiles with seed mySeed)

repeat until the number of items in fileList > howManyRandoms
set onePick to (random number from 1 to totalFiles)
set oneFile to item onePick of myFiles
if oneFile is not in fileList then
set fileList to fileList & oneFile
end if
end
repeat

set aliasList to {}
repeat with i in fileList
set fileAlias to ("mp3 collection:" & i) as alias
set aliasList to aliasList & fileAlias
end repeat

tell application "Toast Titanium 5.0.2"
make new Audio disc
set myDisk to the result
add to myDisk items aliasList
end tell