Search
Tags
1up 3D 9/11 Adventure Games African American Annie Hall Antichrist apple Applescript audience Automat avatar Banjo-Kazooie Banjo-Kazooie: Nuts and Bolts Bernardo Bertolucci Best of Brothers Bruce Springsteen Brutal Legend Call of Duty Casablanca Censorship Charlotte Gainsbourg Children christians cold Controls Crimes and Misdemeanors Criticism Darren Aronofsky Decade Diane Kruger Director's cut Disney District 9 Double Down Drawing drugs Drugstore Cowboy easter easy a Edward Hopper emma stone Empire endings Episodic Essay Feminism fourth of july Fuck You Game Jew Gangs of New York Geometry Wars Grand Theft Auto IV Grim Fandango Heavy Rain Hideo Kojima high school hopelessness Husbands and Wives Hypocrisy Ilsa Inbox Zero Indiana Jones Indiana Jones and the Fate of Atlantis Inglorious Basterds Ingmar Bergman Ingrid Bergman instructional iOS iPad iPhone isolation iTunes James Cameron Jiminy Cricket Jodie Foster John Ford John Hillcoat john lennon jon stewart Jonathan Mann Judgement at Nuremberg KFC Kick-Ass Kieslowski Kill Bill L.A. Noire Lars von Trier Lawrence of Arabia Leon lindsay lohan lists Lolita lonliness love Luc Besson LucasArts Magnolia Martin Scorsese Mass Effect Melanie Laurent Merlin Mann merry christmas Metal Gear Metal Gear Solid 3: Snake Eater Michael Curtiz Michael Powell Millet's The Sower Modern Warfare 2 monkey island music Muslim Mystery Men Natalie Portman Neil Jordan Neill Blomkamp New Year Nominations Oliver Stone Osama Bin Laden Oscar Paths of Glory patriotism patti smith Paul Thomas Anderson Peeping Tom Pinocchio Platoon Poochie Press Programming Psychonauts Quentin Tarantino Racism Raging Bull reactions relationships Religion Remakes Requiem for a Dream Resident Evil 5 Reviews Rez Rob Reiner Rock Band Roman Polanski Sam and Max Sam Rockwell sandy Sarah Silverman Scenes from a Marriage screens Scribblenauts Season 3 Sex Sitting in the Wheat Field smiles Spike Jonze Stanley Kramer Stanley Kubrick steve jobs stupid tales of monkey island Taxi Driver Television Telltale Games Terrorism The American President The Beatles The Crying Game The Dig The Godfather The Last Emporer The office The Road The Sarah Silverman Program The Searchers The Seventh Seal The Simpsons The Wire There Will Be Blood Tim Schafer Tom Cruise Twitter underwhelming valentine's day Video war We're Gonna Play the Wii Tonight When Harry Met Sally Where the Wild Things Are Women Woody Allen Writing

Entries in Applescript (1)

Saturday
Aug132011

Applescript to find albums missing songs

This was the first AppleScript I ever made. In the past, I've had problems with iTunes randomly deleting a song or two from various albums. As a result, I needed something that would run through my library and tell me which albums have missing songs. This script does that, adding the albums to a playlist called "Missing". It's not the best written script, as it was my first, and has a bunch of quirks, such that your library needs to be tagged properly with exact track and disc counts. Also, there's a section of code for checking albums with multiple discs that is poorly written and only works with the library does not have an album with more than 6 discs. Either way, here's something to enjoy.

 

tell application "iTunes"

--Part 1: Get list of every album in the library

set albumList to {}

set musicLibrary to (get view of front browser window)

set musicLibraryName to (get name of musicLibrary)

set trackCount to count of every track of musicLibrary

set processedCount to 1

set new_playlist to make new playlist with properties {name:"Missing"}

repeat while processedCounttrackCount

set theAlbum to album of track processedCount of musicLibrary as string

set add2List to true

if albumList contains theAlbum then set add2List to false

if add2List is true then

set albumList to albumList & (theAlbum as string)

end if

set processedCount to processedCount + 1

end repeat

 

set playlistCount to 0

 

 

repeat with theAlbum in albumList

 

-- gather album tracks

set these_tracks to (file tracks of musicLibrary whose album is theAlbum)

set num_these_tracks to count of these_tracks

set something to (trackof musicLibrary whose track number isand album is theAlbum)

 

set discvariable to 0

 

if disc count of something isthen

set discvariable to track count of something

end if

 

if disc count of something isthen

set something1 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something2 to (trackof musicLibrary whose disc number isand album is theAlbum)

set discvariable to ((track count of something1) + (track count of something2))

end if

if disc count of something isthen

set something1 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something2 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something3 to (trackof musicLibrary whose disc number isand album is theAlbum)

set discvariable to ((track count of something1) + (track count of something2) + (track count of something3))

end if

if disc count of something isthen

set something1 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something2 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something3 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something4 to (trackof musicLibrary whose disc number isand album is theAlbum)

set discvariable to ((track count of something1) + (track count of something2) + (track count of something3) + (track count of something4))

end if

if disc count of something isthen

set something1 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something2 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something3 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something4 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something5 to (trackof musicLibrary whose disc number isand album is theAlbum)

set discvariable to ((track count of something1) + (track count of something2) + (track count of something3) + (track count of something4) + (track count of something5))

end if

if disc count of something isthen

set something1 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something2 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something3 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something4 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something5 to (trackof musicLibrary whose disc number isand album is theAlbum)

set something6 to (trackof musicLibrary whose disc number isand album is theAlbum)

set discvariable to ((track count of something1) + (track count of something2) + (track count of something3) + (track count of something4) + (track count of something5) + (track count of something6))

end if

 

-- if disc count of something is 1 then

if num_these_tracks is not equal to discvariable then

 

-- find highest track number

set hi_track_count to 0

repeat with a_track in these_tracks

set tk_num to track number of a_track

if tk_num > hi_track_count then set hi_track_count to tk_num

end repeat

 

repeat with j fromto num_these_tracks

set a_track to item j of these_tracks

if track number of a_track isthen

duplicate a_track to new_playlist

end if

end repeat

 

repeat with i fromto hi_track_count -- for each number thru hi_track_count...

repeat with j fromto num_these_tracks -- check each track

set a_track to item j of these_tracks

if track number of a_track is i then

duplicate a_track to new_playlist

end if

end repeat

end repeat

end if

 

--end if

end repeat

 

display dialog "Finished making album playlists!" buttons {"OK"} default buttonwith icon note

 

end tell