Created
November 28, 2008 01:58
-
-
Save pjhyett/29877 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/macruby | |
## | |
# Remove any duplicate tracks in iTunes | |
# PJ Hyett was here 11/2008 | |
framework "Cocoa" | |
framework "ScriptingBridge" | |
itunes = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") | |
finder = SBApplication.applicationWithBundleIdentifier("com.apple.Finder") | |
dups = [] | |
seen = Hash.new { |hash, key| hash[key] = true; false } | |
itunes.sources.first.userPlaylists.first.fileTracks.each do |track| | |
if seen[track.name] && track.location.absoluteString =~ /%20[12]\.m4[ap]$/ | |
dups << track | |
end | |
end | |
dups.each do |track| | |
finder.items.objectAtLocation(track.location).delete | |
end | |
# Uncomment the following lines if you want to immediately empty the trash | |
#finder.trash.warnsBeforeEmptying = false | |
#finder.trash.emptySecurity(false) | |
# then run this applescript to remove dead tracks from playlist | |
# http://dougscripts.com/itunes/scripts/ss.php?sp=removedeadsuper | |
# I'd would like to figure out the ScriptingBridge equivalent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment