Maybe. I had rather suspected that the (unbalanced) bracket in the truncated album name was the problem but that doesn’t seem to be the case.
For my problem in general, what I discovered was that when the Mac couldn’t find a track/file (because the name had been truncated and/or modified for Windows), if on the Mac you located the file or double-clicked on it in the Finder, iTunes would “reorganise” the file and then it would be accessible again (with the name restored to the non-truncated version). To process the >22000 tracks in my iTunes library, I tried to simulate this process in a script.
I had to learn by trial and error (and the description in the Internet of characters not allowed in Windows filenames) which characters had to be mapped (replaced by _ in the Finder names). The code I ended up with to do this mapping was
-- Replace characters illegal in Windows file names
set my text item delimiters to {":", ";", "/", "\"", "?", "<", ">", "|", "*", "´", "˜"}
set the nameList to every text item of truncName
set the artistList to every text item of truncArtist
set the albumList to every text item of truncAlbum
set my text item delimiters to "_"
set truncName to the nameList as string
set truncArtist to the artistList as string
set truncAlbum to the albumList as string
set my text item delimiters to ""
Eventually, after I had found out by experiment what forms of apostrophe were acceptable and what others had to be mapped to _, it seems to work. I hadn’t anticipated ASCII 0, however. Since : isn’t allowed in Windows or Mac filenames it was always mapped to _
My assumption now is that iTunes keeps the “full” version of artist, album and name, including characters unacceptable in file- or folder names, in its library whereas in the media area where the files actually exist, the mapped version of the values is used. This would allow iTunes to reconstruct (or “reorganise” as iTunes puts it) names as required.
P.S. I have now discovered that I have more tracks in my library which have albums, etc., with ASCII 0 in their names, not just at the beginning but sometimes in the middle too (e.g. character 23 in the album string in one case I looked at). Just where these ASCII 0’s came from I wouldn’t like to say.
Changing one line in the sample code given above to the following seems to let my script handle these cases too…
set my text item delimiters to ¬
{":", ";", "/", "\"", "?", "<", ">", "|", "*", "´", "˜", ASCII character 0}