tell application "iTunes" set oldencoder to name of current encoder set allencoders to name of every encoder set targettype to (choose from list {"AIFF audio file", "WAV audio file", "Apple Lossless audio file", "MPEG audio file", "AAC audio file"} with prompt "Which kind of songs do you want to convert?" OK button name "Choose" without multiple selections allowed and empty selection allowed) as string if targettype is "false" then error number -128 set newencoder to (choose from list allencoders with prompt "Please Choose an encoder to convert your " & targettype & "s" OK button name "Choose" without multiple selections allowed and empty selection allowed) as string if newencoder is "false" then error number -128 display dialog "WARNING:" & return & return & "After each file conversion, the original audio file will be deleted permanently and only the converted audio file will remain!" with icon 2 set current encoder to encoder newencoder set conitems to every track of playlist 1 of source 1 whose kind is targettype repeat with i from 1 to (number of items in conitems) set fileloc to location of (item i of conitems) tell application "Finder" to set fileloc2 to the POSIX path of file (fileloc as string) convert (item i of conitems) delete (item i of conitems) do shell script "rm " & quote & fileloc2 & quote end repeat set current encoder to encoder oldencoder display dialog (number of items in conitems as string) & " item(s) converted." buttons "Done" default button 1 with icon 1 end tell