I got hints from http://www.dougscripts.com/itunes/ to come up with the following code. But it needs much more improvements.
- I got error when I’m done with the file generation, http://a.imageshack.us/img831/1610/screenshot20100804at113l.png, what’s wrong?
- I don’t need to use “TextEdit” for storing a file, is there better way just store the info to the file?
tell application "iTunes"
if player state is playing then
set sel to current track as list
else if selection is not {} then
set sel to selection
end if
set noSong to ""
set summaryFile to ((path to desktop as Unicode text) & "songs2.txt")
set ff to open for access file summaryFile with write permission
repeat with this_track in sel
set the_lyrics to this_track's lyrics
set {art, nom} to {this_track's artist, this_track's name}
if the_lyrics is not "" then
tell application "TextEdit"
activate
set myVar to art & nom & the_lyrics
write myVar to ff starting at eof
end tell
else
beep
end if
end repeat
end tell
you just had some things out of scope all the opening closing and writing of the text file must be done outside of itunes and texedit is not needed