我使用以下脚本从歌曲标题的文本文件在iTunes中创建播放列表,但似乎在列表中没有带有特殊字符的标题,
--selects file to read from and variables, deletes exisiting tracks
set TheFile to read file "Macintosh HD:Applications:Automator stuff:01b iTunes Scripts:SongListxxx.txt"
tell application "iTunes"
set thePlaylist to playlist "SongListxxx"
try
delete every track of thePlaylist
end try
set MySongs to paragraphs of (TheFile) -- read artist names (separated by newlines) from the file
end tell
--refills playlist
tell application "iTunes"
set theTrack to ""
repeat with AnItem in MySongs -- get all tracks from each artist
set AnItem to (contents of AnItem)
if AnItem is not "" then try -- don't bother with empty names
set MyTracks to (location of file tracks of playlist "Music" whose name is AnItem) --and artist does not contain "Jamie Farrow" and genre is not "Spoken Word")
--can also modify the above from "is" to "contains" or "_begins with_"
add MyTracks to thePlaylist
on error errmess -- oopsie (not found, etc)
--added bit
set theTrack to theTrack & AnItem & return
--display dialog theTrack
--back to script
log errmess -- just log it
end try
end repeat
end tell
Applescript的“名称”属性中的标题为:
Caprice (Le Bal masqué)
Desafinado (Jobim, Mendonça, Hendricks)
Sous le dôme épais (Flower Duet from Lakmé, Delibes)
我的文本文件也与此完全匹配,因此源文件不是错误。
无论如何,Applescript似乎将其读取为:
Caprice (Le Bal masqueÃÅ)
Desafinado (Jobim, Mendonça, Hendricks)
Sous le dôme épais (Flower Duet from Lakmé, Delibes)
因此它们不会出现在已编译的播放列表中。有什么调整可以避免这种情况发生吗?
谢谢。
答案 0 :(得分:1)
文本文件是UTF8编码的,您必须在read
行中指定文本编码,默认为MacRoman
set TheFile to read file "Macintosh HD:Applications:Automator stuff:01b iTunes Scripts:SongListxxx.txt" as «class utf8»