property musicPath : null property extensionList : {".mp3", ".m4a", "m4p"} global songList set songList to {} global counter set counter to 0 try tell application "iTunes" to set podList to name of every source whose kind is iPod on error display dialog "There are no iPods available" buttons {"OK"} default button 1 with icon stop return end try if number of items in podList is 1 then set podName to item 1 of podList else set podName to item 1 of (choose from list podList with prompt "Choose iPod to Add") end if set musicPath to podName & ":iPod_Control:Music" as alias set musicSize to ((size of (info for musicPath)) / (1024 * 1024)) if musicSize is greater than 1024 then set musicSize to "approximately " & (round (musicSize / 1024)) & "GB" else set musicSize to (round musicSize) & "MB" end if display dialog "Your iPod contians " & musicSize & " of music." & return  & "This process may take awhile. Continue?" with icon note my getSongList(musicPath) tell application "iTunes" to set addedTracks to add songList to playlist "Library" of source "Library" display dialog "Added " & (count of addedTracks) & " tracks to library" with icon note on getSongList(theItem) if folder of (info for theItem) then set theContents to list folder theItem set sourceFolder to theItem as string repeat with eachFile in theContents my getSongList(sourceFolder & eachFile as alias) -- For debugging, just do the first 10 files (* set counter to counter + 1 if counter is greater than 9 then return songList end if *) end repeat else if checkExtension(theItem) then set beginning of songList to theItem end if end if end getSongList on checkExtension(theItem) set theFileName to name of (info for theItem) repeat with eachExtension in extensionList if theFileName ends with eachExtension then return true end if end repeat if theFileName is not ".DS_Store" then set extension to "" repeat with i from length of theFileName to 1 by -1 if character i of theFileName is "." then set extension to text i through length of theFileName exit repeat end if end repeat if extension is "" then display dialog (theItem as string) & " was skipped" with icon caution else set oldDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to " " set the theResponse to button returned of  (display dialog "The extension of the file \"" & (theItem as string) &  "\" is not in the approved list:" & return & extensionList  buttons {"Cancel", "Add \"" & extension & "\" to list", "Skip file"}  with icon caution) set AppleScript's text item delimiters to oldDelimiters -- restore delimiters if theResponse is "Skip file" then return false else set end of extensionList to extension return true end if end if end if return false end checkExtension