How do you locate corrupted iTunes files?

Discussion in 'Mac Apps and Mac App Store' started by kavika411, Mar 15, 2007.

  1. kavika411 macrumors 6502a


    Jan 8, 2006
    Thank you for reading this. I regularly find music tracks which will not play out of the iTunes library (I get that darn spinning beach ball), nor will the synch on to the iPod (they cause the synching process to hang up and I get an error message). I am assuming they are corrupted, if that is in fact the proper word.

    Is there something built into iTunes, an applescript, anything at all out there which can go through my library (I have about 12,000 songs) and locate all of these corrupt files so I can re-rip them? Or perhaps is there something which can fix them? Thank you.
  2. GimmeSlack12 macrumors 603


    Apr 29, 2005
    San Francisco
    I have this Applescript that removes dead linked iTunes songs, but not sure about your "corrupted" files. Either way give it a shot.
    To install:

    Go to your Computer Library Folder (NOT your User Library Folder).
    Open the Library>iTunes>Scripts (if any of these folders don't exist, then create them).
    Place this Applescript (below) in the Scripts folder.

    Quit and relaunch iTunes you should now see the Applescript icon in the menu bar with this script in it. Just select it and see how that does.

    "Super Remove Dead Tracks" for iTunes
    written by Doug Adams
    v1.5 october 26 2005
    -- prevents error when trying to delete empty Smart Playlists and/or playlist that can't be deleted (Party Shuffle, Podcasts, etc)
    -- code tweaks
    v1.0 sep 25 2003
    -- initial release
    Get more free AppleScripts and info on writing your own
    at Doug's AppleScripts for iTunes
    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
    Get a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    or visit
    (* the number below is the number of tracks
    to count before reporting progress -
    you can change this number to a larger or smaller number. 
    If you set it to zero, you will not see the progress message *)
    property progress_factor : 500
    tell application "iTunes"
    	display dialog "Super Remove Dead Tracks" & return & return & ¬
    		"Removes tracks whose files are missing or deleted, so-called" & ¬
    		"\"dead\" tracks designated with (!) next to the track name." buttons ¬
    		{"Cancel", "Proceed..."} default button 2
    	set mainLibrary to library playlist 1
    	set totalTracks to count of file tracks of mainLibrary
    	set all_playlists to user playlists whose smart is false -- don't delete Smart Playlists later
    	set deleted_tracks to 0
    	set all_checked_tracks to 0
    	set countem to ""
    	set oldfi to fixed indexing
    	set fixed indexing to true
    	repeat with t from totalTracks to 1 by -1
    			set this_track to file track t of mainLibrary
    			if this_track's location is missing value then
    				delete this_track
    				set deleted_tracks to deleted_tracks + 1
    			end if
    			set all_checked_tracks to all_checked_tracks + 1
    			if frontmost then
    				if (progress_factor is not 0) and (all_checked_tracks mod progress_factor) is 0 then
    					if deleted_tracks is greater than 0 then ¬
    						set countem to (deleted_tracks & " dead tracks removed so far...")
    					if frontmost is true then display dialog (all_checked_tracks as string) & ¬
    						" tracks checked..." & ¬
    						return & countem buttons {"Cancel", «data utxt266B»} giving up after 1
    				end if
    			end if
    		end try
    	end repeat
    	set fixed indexing to oldfi
    	repeat with this_playlist in all_playlists
    		if (get count of tracks of this_playlist) is 0 then
    				delete playlist this_playlist
    			end try
    		end if
    	end repeat
    	if deleted_tracks is greater than 0 then
    		set ps to " was"
    		if deleted_tracks is not 1 then set ps to "s were"
    		display dialog "Finished removing \"dead\" tracks." & return & ¬
    			deleted_tracks & " track" & ps & ¬
    			" removed." buttons {"Thanks"} default button 1 with icon 1
    		if gave up of (display dialog "It was not necessary to remove any tracks." buttons {"Thanks"} ¬
    			default button 1 with icon 1 giving up after 15) is true then error number -128
    	end if
    end tell
    EDIT: To use this code in an applescript open up Script Editor (found in Applications>Applescript>) and then copy and paste this code into a new script. Then save the file into the directories noted above.
  3. RugoseCone macrumors 6502

    Aug 22, 2002
    Usually files that are causing me trouble will have a grey triangle with an exclamation point in the center, next to the song name. This is in itunes whilst browsing the library in list mode.
  4. GimmeSlack12 macrumors 603


    Apr 29, 2005
    San Francisco
    The script above will take care of that problem too. (actually its the main use of the script).

Share This Page