Checking for duplicates in lists
Checking for duplicates in lists
- Subject: Checking for duplicates in lists
- From: Richard Rönnbäck <email@hidden>
- Date: Mon, 29 Dec 2003 22:15:14 +0100
I need some scripts for dealing with possible duplicates in iTunes.
Performance is critical for the user experience so I thought that the best
way would be to see if there are multiple occurrences in a list.
However, the subroutines I found at Apple's site for working with lists are
way too slow so I came up with the method below, which seems to work and be
reasonably fast.
Any suggestions on how to further improve speed would nevertheless would be
most welcome
The list of possible duplicates will of course go through additional
processing
tell application "iTunes"
set mySource to (source 1 whose name is "Library")
set myPlayList to (playlist 1 whose name is "Library") of mySource
set myTracks to (name of file tracks) of myPlayList
set myCount to count of myTracks
set myDuplicates to {}
repeat with myCounter from 1 to (myCount - 1)
if (item myCounter of myTracks) is in (items (myCounter + 1) thru
myCount of myTracks) then
if (item myCounter of myTracks) is not in myDuplicates then
copy item myCounter of myTracks to end of myDuplicates
end if
end if
end repeat
if (item myCounter of myTracks) is in (items (myCounter) thru myCount of
myTracks) then
if (item myCounter of myTracks) is not in myDuplicates then
copy item myCounter of myTracks to end of myDuplicates
end if
end if
choose from list myDuplicates
end tell
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.