I really don't like AppleScript. I need my {'s and ;'s to program.
However, I'm trying to make a simple script that can log my current iTunes track info to a file. I've got the logging part down, but things start breaking when non-alphanumerical characters enter the picture. For instance, the following script tells me "iTunes got an error: sh: line 1: Union: command not found" when I play a track by Alison Krauss & Union Station and run this. Why on earch is it trying to handle the contents of a string as AppleScript code? That's just crazy. I've tried putting string() around the_artist, but now I'm just guessing (like I wasn't before, hah).
Yes, I'm aware that this is rather ugly.
Code:
tell application "System Events"
if ((application processes whose (name is equal to "iTunes")) count) is greater than 0 then
tell application "iTunes"
if player state is playing then
set the_artist to artist of current track
set the_song to name of current track
set the_album to album of current track
if the_artist is not missing value then
if the_album is not missing value then
if the_song is not missing value then
do shell script "echo " & the_artist 'and other stuff
end if
end if
end if
end if
end tell
end if
end tell
Thanks!