script o
property Les_tracks : missing value
end script
set i to 1
tell application "iTunes"
set o's Les_tracks to selection
if o's Les_tracks is {} then return -- aucune selection, quitte le script
set total to (count o's Les_tracks)
repeat while i < total
tell item i of o's Les_tracks to set {titre, Lartiste, Lalbum} to {name, artist, album}
repeat with k from (i + 1) to total --ceci va enlever tous les doublons à la suite ayant le même titre, sauf le premier en surveillant que ca soit le meme album
tell item k of o's Les_tracks to set {titre2, Lartiste2, Lalbum2, T_ID} to {name, artist, album, database ID}
if titre2 is titre and Lartiste is Lartiste2 and Lalbum is Lalbum2 then
tell (get first track of library playlist 1 whose database ID is T_ID)
set the_path to location
delete -- enleve de la bibliotheque
my delete_file(the_path) --mets le fichier dans la corbeille
end tell
else
exit repeat
end if
end repeat
set i to k -- mets la variable (i) à l'index de l'élément dont le titre est différent
end repeat
end tell
on delete_file(t_file)
try
tell application "Finder" to delete t_file -- mets le fichier à la corbeille.
end try
end delete_file