tell application "iTunes" set lastTimes to {} set longestTime to 0 -- set lastTimes to the (played date of every track of playlist "AllMusic") -- da:removed, replaced with the following: set musicLibrary to (some playlist whose special kind is Music) set lastTimes to the (played date of every track of musicLibrary) set curDate to (get current date) repeat with i in lastTimes try -- da: added try in case a song has no played date set tempVariable to curDate - i if tempVariable is greater than longestTime then set longestTime to tempVariable end if end try -- da end repeat set daysAgo to (longestTime div 86400) set overDay to (longestTime / 86400) - daysAgo set decimalHours to (overDay * 24) set andHours to overDay div (1 / 24) set overHours to (overDay * 24) - andHours set andMinutes to overHours div (1 / 60) if daysAgo is 1 then set daysWord to " day" else set daysWord to " days" end if if andHours is 1 then set hoursWord to " hour" else set hoursWord to " hours" end if if andMinutes is 1 then set minutesWord to " minute" else set minutesWord to " minutes" end if display dialog "The oldest song was last played " & daysAgo & daysWord & " and " & andHours & hoursWord & " and " & andMinutes & minutesWord & " ago." set daysSincePlayed to "" display dialog "Enter the number of days since last played:" default answer the daysSincePlayed copy the result as list to {daysSincePlayed, the button_pressed} set targetDate to curDate - daysSincePlayed * days set cobwebbedLibrary to the tracks of musicLibrary as list if user playlist "Dustiest Albums" exists then -- da: added option to add or replace if button returned of (display dialog "\"Dustiest Albums\" playlist already exists. Add new albums to it or Replace current albums in it?" buttons {"Add", "Replace"}) is "replace" then try delete tracks of user playlist "Dustiest Albums" end try end if else make new user playlist with properties {name:"Dustiest Albums", shuffle:false, song repeat:none} end if set dustiestSong to "" set dustiestAlbum to "" set dupedAlbums to {} as list if the (count of tracks of user playlist "Dustiest Albums") is 0 then set alreadylistedDusty to {} else set alreadylistedDusty to the name of every track of user playlist "Dustiest Albums" end if repeat with i from 1 to the count of cobwebbedLibrary set dustiestSong to item i of cobwebbedLibrary set playedDate to played date of dustiestSong if playedDate is less than targetDate then if (album of dustiestSong is not in dupedAlbums) and (name of dustiestSong is not in alreadylistedDusty) then set dustiestAlbum to album of dustiestSong set dupedAlbums to dupedAlbums & dustiestAlbum duplicate (every track of library playlist 1 whose album is dustiestAlbum) to user playlist "Dustiest Albums" end if end if end repeat display dialog "Transfer Complete" end tell