Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tell application "iTunes"
- set sel to selection
- if sel is {} then
- set is_ct to player position is not missing value
- if is_ct then set sel to current track as list
- end if
- set ditext to "Trash " & (count sel)
- if (count sel) is not 1 then
- set ditext to (ditext & " tracks?")
- else
- set ditext to (ditext & " track?")
- end if
- display dialog ditext buttons {"Yes, delete.", "No, Cancel"} default button 2
- if button returned of result = "Yes, delete." then
- repeat with T in sel
- try -- audio streams don't have locations
- set L to location of T
- on error errMSG number errNUM
- if errNUM = -1728 then
- set L to missing value
- else
- error errMSG number errNUM
- end if
- end try
- set N to name of T
- set in_lib to missing value
- if L is not missing value then -- typical branch for files
- repeat with R in search playlist "Library" for N only songs
- if location of R is L then
- set in_lib to R
- exit repeat
- end if
- end repeat
- if in_lib is not missing value then
- delete in_lib
- tell application "Finder"
- delete L -- otherwise the file just dangles
- end tell -- but, empty folders will still dangle
- end if
- else -- branch for audiosstreams interradio etc deletes all matching url addess
- if class of T is URL track then
- set A to address of T
- repeat with R in search playlist "Library" for N only songs
- if address of R is equal to A and class of R is equal to class of T then
- delete R
- end if
- end repeat
- else
- error "Dont know what to do!!!" number -1
- end if
- end if
- end repeat
- end if
- end tell
- -- Trash Track: Find song in Library and delete it.
- -- Allows one to delete files w/o having to find them in the Library.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement