Search This Blog

Sunday 25 April 2010

Mac: Extracting lyrics, saving

#

tell application "iTunes"
    set sel to selection
   
    repeat with this_track in sel
        set the_lyrics to this_track's lyrics
        set {art, alb, nom} to {this_track's artist, this_track's album, this_track's name}
        if the_lyrics is not "" then
            set theName to (art & " - " & alb & " - " & nom)
            set theDocumentPath to (("/users//documents/music/lyrics/") & theName & ".txt") as string
            log the_lyrics
            set theCommand to "echo " & quoted form of the_lyrics & " > " & quoted form of POSIX path of theDocumentPath
            do shell script theCommand
        else
            beep
        end if
    end repeat
end tell