You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

📰 Newsroom Update

Billie Eilish is Apple Music’s Artist of the Year for 2024. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

how to delete duplicated songs all at one time?

I would like to get help deleting duplicated songs, I do not know how they got their in the first place.

Windows 7

Posted on Aug 28, 2011 10:29 AM

Reply
Question marked as Top-ranking reply

Posted on Apr 6, 2017 10:14 PM

Some how I got duplicates of my library on iTunes and to get rid of all the new duplicates I went to the library I looked for the date the new duplicate songs were added to the library then I went to columns and where you see Artist, song,

bit rate, time, etc and added 'date added' once that's done click on the box enclosing 'date added' and you will see all songs added by date. Proceed to the last one of the songs with that date press command to highlight it then scroll all the way to the first song and press 'shift' to highlight all of the songs added on that date then simply press delete.

you will be asked if you want to delete these songs...That's it.

483 replies

Jun 18, 2012 1:53 AM in response to Tibeerius

My initial aim was to keep iTunes connected to the first copy of a track that was added to the library. This will normally be the one without the trailing digit, though if you subsequently rename the artist or the album, trigger the restructuring of the library, or consolidate files that were previously outside the media folder, then this will become indeterminate. If both files have the same date added value that would suggest the files were already duplicated before being added to a new library making the choice somewhat arbitrary. I assume that in this case both files have the same size so we're not looking at preserving the larger, better quality file?


Although I probably could add some extra steps to the script it would be much easier to uncheck Keep iTunes Media folder organized, click OK, then turn it on again, assuming of course that you normally let iTunes organize your filenames.


tt2

Jun 26, 2012 1:47 PM in response to Community User

Have you used the Show Exact Duplicates feature on the main Music playlist or have you used a regular playlist which could have had the same tracks added to it twice?


Each entry in the iTunes database has a unique identity, its LibraryPersistentID. In the line with the error it would seem that that very same object is being scheduled for deletion a second time. When designing and testing the script I hadn't considered that could be a possibility but when using a regular playlist as the source for the script it might be. Media sources and smart playlists should contain at most one instance of each LibraryPersistentID, but regular playlists can have the same song appear more than once if you wish.


Right now I can't think of another reason the error might occur. Funnily enough I've been thinking about changing the way my scripts work so that the first pass reads in all the LibraryPersistentIDs into an array (which I can see now needs to be deduped also for use with regular lists). That way if the script is processing a smart playlist in such a way the update causes the item to fall out of the list the script still has access to it for any other changes. So far it hasn't happened to me often enough to consider it really worth the effort, and then it has only been in a personal script where I've merged a few different fixes for tidying up podcasts into one script. Perhaps this is a hint I should investigate the idea further.


tt2

Aug 4, 2012 12:02 PM in response to turingtest2

Hi Turingtest2


It looks like you've put a lot of work into this and in theory I want to say a huge thank you for what you're offering to people. But so far it's not working for me. I have over 12,000 duplicates, but I have been testing it on a smaller number and it's deleting the only copy of the file. I.e. I select two entries in iTunes that are pointing towards the same file on the local drive, and the script removes the source file instead of just removing the duplicate entry in iTunes.


Do you have any suggestions?

Aug 4, 2012 12:25 PM in response to Michael Cawood

Michael Cawood wrote:


...I have been testing it on a smaller number and it's deleting the only copy of the file. I.e. I select two entries in iTunes that are pointing towards the same file on the local drive, and the script removes the source file instead of just removing the duplicate entry in iTunes.


Eeek! I hope you read my warning about backing up first. At a guess you've got a "multiple paths to the same file" issue. I haven't yet worked out how to resolve that issue in a generic way but I should be able to cook up a workaround for a specific case. Could you post some sample paths? Are there just two?


tt2

Aug 11, 2012 11:39 AM in response to Suavecito69

Okay, I've read the first (2) pages plus the last page, so I apologize if I missed it. I do have a "backup" so I'm not concerned about having lost files at this point either....


Anyway, I've really hosed up my library after having a hard drive failure. I had copied my music from my iPod to more than one PC and when attempting to get ALL of my music back, in case all libraries weren't identical, I ended up copying multiple versions/copies. My iPod had (4) copies of the same song in some cases !! 😀


At this point, I've copied my library to my wife's laptop and added them to her iTunes libary, then did Shift, File, Display Duplicates. Since I have thousands of songs x 2 or x 3 or x 4, selecting all but one of each is very impractical. I didn't realize that was what I was supposed to do as the first error message I rec'd was "Selecting at least two songs...". So, I did "Crtl+A" 🙂 and then ran your script. I fear I am going to delete ALL of the songs at this point.


Did I click the 2nd dialog too quicly as I thought it had three options for cleaning up, with one labeled "safer" ? I clicked "Yes" on that dialog though.

Aug 11, 2012 11:50 AM in response to HallStevenson

Ctrl-A is fine. Annoyingly the script interface doesn't have access to the collection of tracks listed on the screen after you used Display Exact Duplicates, or typed something in the search box. You might see 2, 20 or 200 tracks, but the script sees the entire playlist unless you select what it displayed.


There are three main classes of duplicates, logical, physical, and different sized. Yes deletes all three, no (safer) deletes just the first two. Since largest files are preserved you're unlikely to have lost out.


And no, it should not delete all the selected songs. No need for a script to do that. It should leave you with one copy of each unique track.


tt2

Aug 11, 2012 3:27 PM in response to turingtest2

That's good to hear ! I restored all of the MP3 from the Recyle Bin and re-ran the script. Not sure if it's running though.... and it's been going for a while (at least an hour or more). I am past the 2nd dialog though and I did pick the "No" option, i.e. the one described as "safer".


I saw you mention that iTunes will update it's database quite frequently when making changes and this will slow it down. It's dealing with 8gb of duplicate files.

Aug 18, 2012 9:33 AM in response to turingtest2

"I went ahead and debugged the problem. It turns out there were '/' characters in some of the names pulled from playlists, because they were done on a Linux system. That's what was confusing things. I'd suggest a global replace of '/' with '\' before Set objFolder=objShell.Namespace(strFolderParent) to avoid that problem." ======== "Great, thanks for that. I'll post a revision up later. I'm on my iPad rather than at a PC just now..." ======== I've just ran into the same or similar issue. The exact details are: Windows Script Host ----------------------- Script: C:\Users\Amy\Deduper.vbs Line: 309 Char: 7 Error: Object required: 'T' Code: 800A01A8 Source: Microsoft VBScript runtime error I downloaded the script just a week or two ago. Is it encountering something different than what you guys discovered back then ?

Aug 18, 2012 10:15 AM in response to turingtest2

752 tracks selected.


I chose "yes" at first dialog and "no" at second. I also tried "yes" at second on a subsequent run with same resulting error.


I wasn't doing anything with library - I let it run in the background while I browse the internet, etc, etc.


Off-topic: I noticed many, if not most, of the duplicates are the original album's version and also from a "greatest hits" album. Yeah, they're likely identical, but since they're from different albums, how could you get iTunes to deal with this better ?

Aug 18, 2012 10:24 AM in response to HallStevenson

You should be holding down shift, selecting File > Display Exact Duplicates and then selecting the results before running the script. Original Album and Greatest Hits versions of the same song in these circumstances shouldn't be displayed, unless you have multiple copies of the tracks from both albums.


Still scratching my head on this one. I'll have to think about about adding some debugging code to reveal more... 😕


tt2

Aug 18, 2012 10:37 AM in response to HallStevenson

It would be interesting to see the details for two obviously different copies that are being displayed. I've not had that problem before.


I may not have time to rifle through the code this evening but it might help to answer No to the first prompt in order to set up track-by-track confirmation. That way you might get the detail of which track is causing a problem.


tt2

Aug 18, 2012 11:32 AM in response to turingtest2

I apologize (and feel silly now). I must not have done the Shift option. Just did it again and get (204) duplicates. Will re-run your script now...


Okay, I still get the error by answering Yes, then No.


I still get the error by answering Yes, then Yes.


Now for the one-by-one attempt. By the way, it went from (204), to (202), and now is at (200), so it seems to be processing a couple each time before it hits something it doesn't like...


It prompted me to delete a song and when I clicked Yes, it popped up the error again. I know what song it is, of course. By the way, what order does it go in ? The song is # 59 and # 60 from the Display Duplicates listing.


I just removed those tracks.... and it still failed 😟


I'll try one-by-one again.

Aug 18, 2012 11:49 AM in response to HallStevenson

It processes tracks in reverse order. If there are 10 tracks selected and it deleted track 1, say, all the other tracks would shift down by one and the script would lose it's place... If the tracks are listed in an order which puts the duplicates next to each other it will delete one or the other depending upon which is newer or smaller but will typically be deleting alternate tracks.


Hmm, are you running the script on the main Music playlist? If it is a manual playlist you could have dragged the same songs into it more than once, but deleting one instance would cause the same sort of problems as above.


This leads me to two ideas that I've been mulling over but I should really find the time to complete. First a script to eliminate repeat entries in a playlist for the same object. Second a reworking of my scripts so that the first job they to is make their own internal deduped list of objects which they then work with to prevent this kind of problem...


tt2

how to delete duplicated songs all at one time?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.