(* * random selection of MP3 tracks under iTunes for copying on some memory card * * For adapting, you must certainly change the first properties: * diskname is the name of your mounted volume * libname and to some extent kindname are language dependent strings * maxsize is the maximum size you want to transfer (for safety) * musicfolder is the folder in which to find audio files *) -- The name of the disk to fill (this is the label of the card) property diskname : "JE1GB" -- Apparently some limits to multilingualism property libname : "Bibliothque" -- name of the main library property kindname : "MPEG" -- string found in MP3 kind tag -- The maximum size to be transferred in bytes property maxsize : 500000000 -- 100MB is 100000000 -- The toplevel folder in which to find MP3 property musicfolder : "AUDIO" on run -- Here we could additionnaly empty the Card AUDIO folder and Trash -- Get available size on disk (I do not consider filling more than 3/4 this space) tell application "Finder" to set avail to (the free space of disk diskname) * 0.75 if avail is greater than maxsize then set avail to maxsize -- Open iTunes tell application "iTunes" activate tell source libname tell playlist libname -- While quota not exceeded repeat until avail 0 -- Select random track set this_track to some track set track_size to the size of this_track set track_type to the kind of this_track set track_file to the location of this_track -- If playable, find out yourself what to do if not if track_type contains kindname then --display dialog "File: " & track_file & -- return & "Type: " & track_type & -- return & "Size: " & track_size & -- return & "Left: " & maxsize & -- return & return buttons {"OK"} if track_size is greater than avail then -- BEWARE: It stops at the first file exceeding quotas this is a problem with some huge files in the Library set avail to 0 else -- Update quota set avail to avail - track_size -- Copy file (replacing useful if doubles or not emptied before) tell application "Finder" to duplicate file track_file to folder musicfolder of disk diskname with replacing end if end if end repeat end tell end tell end tell end run