I’m in the process of writing an applescript to sync song ratings across our local network, and I’m having some issues with file reading and iTunes compatibility. I have the following script writing the current track’s info to the server:
tell application "iTunes"
set song to name of current track
set art to artist of current track
set alb to album of current track
set f to (open for access file "SAM:300:Documents:serverrate:sam" with write permission)
set eof of f to 0
write song & "|" & art & "|" & alb to f
close access f
end tell
This works exactly as I’d expect. The next part is where It gets confusing:
set f to (read alias "SAM:300:Documents:serverrate:sam" using delimiter "|" as string)
set song to item 1 of f as text
set art to item 2 of f as string
set alb to item 3 of f as text
tell application "iTunes"
every track of library playlist 1 whose artist is art
end tell
This returns an empty list, however if I simply replace art with “Led Zeppelin” for example, it comes up with a list of 33 file tracks. I then went on to test and found that get art returns “Led Zeppelin” and class of art is string, which is the same as class of “Led Zeppelin”, so I guess what I’m trying to say is that I no longer have any sort of clue what’s going on. Any ideas?