Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tell application "iTunes"
- -- globals
- set thePlaylist to "jtunes"
- set theMaxSizeInMegabytes to 500
- -- get the list of albums
- set allAlbumsList to {}
- set albumList to album of file tracks of library playlist "Library" whose kind contains "audio"
- set tcount to count albumList
- repeat with i from 1 to tcount
- tell my albumList's item i to if it is not in my allAlbumsList and it is not "" then set end of my allAlbumsList to it
- end repeat
- -- create and or delete the playlist
- if exists (some user playlist whose name is thePlaylist) then delete (some user playlist whose name is thePlaylist)
- set myPlaylist to make new playlist with properties {name:thePlaylist}
- -- fill the playlist
- set selectedAlbums to {}
- set selectedSize to 0
- set done to false
- repeat until done
- tell (some item of allAlbumsList) to if (it is not in selectedAlbums) then set end of selectedAlbums to it
- set theAlbum to end of selectedAlbums
- set albumSize to 0
- set albumTracks to (every file track of library playlist "Library" whose album is theAlbum)
- repeat with aTrack in albumTracks
- set albumSize to albumSize + (size of aTrack)
- end repeat
- set albumSize to albumSize / 1024 / 1024
- if albumSize + selectedSize > theMaxSizeInMegabytes then
- display dialog "have a great day"
- set done to true
- else
- set selectedSize to selectedSize + albumSize
- set albumTracks to (every file track of library playlist "Library" whose album is theAlbum)
- repeat with aTrack in albumTracks
- duplicate aTrack to myPlaylist
- end repeat
- end if
- end repeat
- end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement