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.

Eliminating duplicate songs in music library.

I have been battling for years with unwanted duplication in my music library when I inadvertently upload the same CD twice, or even when a track from, say Don Giovanni also appears in a track from Greatest HIts. Finally I wrote a script that works. It is a bit lengthy and has instructions on how to use it, so if anyone is interested, let me know. I will try to copy it below as a reply.

Posted on Sep 27, 2024 10:19 AM

Reply
1 reply

Sep 27, 2024 10:20 AM in response to bjorn92

-- attempt to use script editor to eliminate duplicates in my liobrary


--- export music loibrary


-- open music, choose songs, sort on album. disc, track, then select all songs\


-- then run the script


-- then sort on comment


-- then delete all tracks with the "suspect" comment


--


-- in this script, track number is the number in the selection, not in in album


----


--


set myComment to ""


set prevAlbum to ""


set prevTitle to ""


set prevTrack to {}


set prevDisk to {}


set prevTime to {}


tell application "Music"


set selectedTracks to selection -- run this after opening the music library, sonngs, select all


repeat with theTrack in selectedTracks


tell theTrack


set comment to "ok"


-- set sort album to "ok"


if (album = prevAlbum and disc number = prevDisk and track number = prevTrack and time = prevTime) then


set comment to "suspect"


-- set sort album to "suspect"


end if


set prevAlbum to album


set prevArtist to artist


set prevTrack to track number


set prevDisk to disc number


set prevTime to time



--return {prevAlbum, prevDisk, prevTrack, prevTime} --


--


end tell


end repeat



return {prevAlbum, prevDisk, prevTrack, prevTime} --



end tell



Eliminating duplicate songs in music library.

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