{"id":58,"date":"2009-07-11T16:21:00","date_gmt":"2009-07-11T20:21:00","guid":{"rendered":"http:\/\/clusterbleep.net\/blog\/2009\/07\/remove-duplicate-files-in-itunes\/"},"modified":"2009-07-11T16:21:00","modified_gmt":"2009-07-11T20:21:00","slug":"remove-duplicate-files-in-itunes","status":"publish","type":"post","link":"http:\/\/clusterbleep.net\/blog\/2009\/07\/11\/remove-duplicate-files-in-itunes\/","title":{"rendered":"Remove Duplicate Files in iTunes"},"content":{"rendered":"<p>Apple, in its inifinite idiocy, decided that iTunes does not need an easy way to remove duplicate songs en masse. I recently copied my MP3 libraries from three different sources into one place, so there were a lot of duplicates. Rather than take off work for the next two months to remove the duplicates one at a time through iTunes, I whipped up a quick Python script to remove the files.<\/p>\n<p>The duplicates had a single space followed by 1 or two at the end of the file name. For instance:<br \/>Blondie &#8211; Heart of Glass.mp3<br \/>Blondie &#8211; Heart of Glass 1.mp3<br \/>Blondie &#8211; Heart of Glass 2.mp3<\/p>\n<p>My simple script uses this situation to recurively decend through multiple layers of folders and delete the extra files. Here it is:<\/p>\n<pre>import os<br \/><br \/>path = \"\/Volumes\/Untitled\/Music\"<br \/><br \/>for dirpath, dirnames, filenames in os.walk(path):<br \/>for file in filenames:<br \/>f = str(file).strip()<br \/>if f.endswith(' 1.mp3') or f.endswith(' 2.mp3'):<br \/>fullpath = os.path.join(dirpath, file)<br \/>print 'Deleting ' + fullpath<br \/>os.remove(fullpath)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Apple, in its inifinite idiocy, decided that iTunes does not need an easy way to remove duplicate songs en masse. I recently copied my MP3 libraries from three different sources into one place, so there were a lot of duplicates. &hellip; <a href=\"http:\/\/clusterbleep.net\/blog\/2009\/07\/11\/remove-duplicate-files-in-itunes\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[15,14,7],"tags":[],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-grpug","category-python","category-tech"],"_links":{"self":[{"href":"http:\/\/clusterbleep.net\/blog\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/clusterbleep.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/clusterbleep.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/clusterbleep.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/clusterbleep.net\/blog\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":0,"href":"http:\/\/clusterbleep.net\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"wp:attachment":[{"href":"http:\/\/clusterbleep.net\/blog\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/clusterbleep.net\/blog\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/clusterbleep.net\/blog\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}