There are some rather different looking things in this code. When sending commands to iTunes you should use a tell application. iTunes works a lot with track, playlist and source to identify a unique object. For example just to identify a track I would normally do something like track 1 of playlist 2 of source 1 which would identify the first track of music in my library. iTunes structures can vary but this is what it does on my iMac.
tell application "iTunes"
name of playlist 2 -- Returns Music
name of playlist 1 -- Returns Library
name of it -- Returns "iTunes"
track 1 of playlist 2 of source 1 -- Returns file track id 50308 of user playlist id 49640 of source id 66
composer of every track of playlist 2 of source 1 -- Returns the name of every composer in the library
work of every track of playlist 2 of source 1 -- Returns a huge list of empty strings on my iMac
end tell
The “it” in the script is pointing to iTunes as a whole, and not to any of the useful objects in iTunes. I don’t have anything in my library that has “work” set to anything so I have nothing but empty strings for work.
I’m not sure what you were trying to do but the following returns a boolean value not a number:
(count of (composer of every track of playlist 2 of source 1)) ≠ (count of (work of every track of playlist 2 of source 1))
If you weren’t trying to do that comparison what is written makes no sense. If you tried to compare the count of the first part with the attributes of the second part it will never return anything but false.
It would be best to say what you wanted to do. This script has a lot of errors in it. It would be constructive to think of references to things as being done with tracks, playlists and sources.
Bill