I lost a big chunk of my iTunes library due to a disk failure. The database is fine, but the song files are missing. Luckily for me, iTunes will let me reimport the CDs and preserve my existing playlists, play counts, etc. iTunes is set to import automatically on disc insertion, so when I stick a CD in I get this dialog:

One or more of the songs you have selected to import have already been imported. Do you want to replace existing songs and import them again? [Replace Existing] [Cancel] [Don't Replace]

So far so good. The trouble is that my library is hosted on a headless G4 Mini, and it's inconvenient to hit "Replace Existing" every time. Even if I connect a monitor and keyboard, the dialog takes a little while to come up, and I'd like to just swap CDs in and out whenever I walk through the living room. There's a few hundred CDs to re-import so I don't want to babysit the process.

I thought about writing an AppleScript to push "Replace Existing" for me, but there doesn't seem to be a way to wait on dialog events. I looked around the iTunes prefs files, etc., for some "always replace existing" option, but no luck.

I figure this is a long shot, but does anyone have any ideas on how to skip the "Replace Existing" dialog or otherwise make this process go more smoothly?

2 Answers 2


If you have enough disk space, maybe you can import the CDs into a new iTunes library, and when it is all done, import again (in one go) from there into the real one?

  • Yep, that works! Unfortunately I discovered that the reimport feature is only triggered if the title/artist/album match exactly. Since preserving my metadata was the whole point of re-importing, I now need to rethink the entire approach. But you answered this question, thanks!
    – Dewb
    Dec 13, 2010 at 22:52
tell application "System Events"
    tell process "iTunes"
            -- say "Checking for Dialog Box"
                 click button "Replace Existing" of window 1
                 -- say "Clicked Replace Existing. CD import can now proceed."
            on error
            -- say "No Dialog Box Found. Will retry in 10 seconds"
            end try
            -- say "Good Grief"
            delay 10
        end repeat
    end tell
end tell
  • Suggest making your answer a little clearer by prefacing it with something like, "Here's an Applescript that may help you. Enter this into Script Editor then..." (either compile it as a droplet, or run it, or whatever the user needs to do to get it to interact with iTunes.) Even if the question asker doesn't need this explanation, future readers may need it.
    – gosmond
    Feb 21, 2013 at 2:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .