Monthly Archives: September 2013

Remove duplicates from iTunes playlist

UPDATE: Script could be found on BitBucket now – https://bitbucket.org/hydralien/tools/src/8e751cbd676eb7c2604d4e2e25633f9291e631f0/apple/iTunesDedupe.applescript?at=master

If one adds music to iTunes playlist by dragging them files in (without moving to iTunes library), one might end up with a fair number of duplicates. And one might get frustrated about it.

ALso, one might even go and solve it, and then share for other suffering fellas – like this: http://hydralien.net/storage/apps/nodupes.dmg

NOTE: playlist should be sorted by name. And it makes sense to export a playlist for backup reasons – for I give no warranties here.

Code is included to the image – but let it rest below as well. FTR to launch/edit it, run AppleScript Editor (use Spotlight) – it’s simple but nice tool to write AppleScript apps.

 

tell application "iTunes"
display dialog "Gimme playlist name" default answer ""
set plName to the text returned of the result
set curPl to user playlist plName -- current playlist
set dupes to {}
set prevTrack to {"", 0}
set trackNo to 1
repeat with aTrack in every track of curPl
set curTrack to {get name of aTrack, get time of aTrack}
if curTrack = prevTrack then
set the end of dupes to trackNo
end if
set trackNo to trackNo + 1
set prevTrack to curTrack
end repeat
set dupePos to 0
repeat with dupe in dupes
set rmTrack to dupe - dupePos
-- log rmTrack
delete track rmTrack of curPl
set dupePos to dupePos + 1
end repeat
set dialogLine to "Deleted " & (count dupes) & " dupes in " & plName & " playlist"
display dialog dialogLine buttons {"OK"}
end tell

Hello horde!

I’m gonna reflect the Info page content here – because it’s, well, the same.

This is all about tech. It’s hard to describe, really – because things I’m planning to post here, they’re not connected to any particular subject, scope or kind of tech world. It could be MySQL table structure hint, followed by new action camera review and then notes about flight aboard that trendy Dreamliner. Or a videogame review. Or even something as abstract as “if I were a giant robot in a shape of a cow” thoughts. But it’s all tech, you see.

“Why do we need another tech blog?”, you might ask. And my answer would be “For no reason, you certainly do not”. But I do. This is a storage, really – different stuff that doesn’t fit Evernote, that exceeds simple occasional note form, begs for publicity, threatens to get lost and wither forever otherwise.

So to summarize and emphasize: I’m a geek and a nerd, planning to push the entropy a tad bit more uphill by littering digital world with mostly useless (to the world) but (sometimes) precious (to me) bits and pieces, shaped in words.

Fin. (not related to a fish)