我试图创建一个读取文本文件并将内容放入列表的 AppleScript。该文件是一个简单的文本文件,其中每一行如下所示:example-"example"
第一个是文件名,另一个是文件夹名。
这是我现在的代码:
set listOfShows to {}
set theFile to readFile("/Users/anders/Desktop/test.txt")
set Shows to read theFile using delimiter return
repeat with nextLine in Shows
if length of nextLine is greater than 0 then
copy nextLine to the end of listOfShows
end if
end repeat
choose from list listOfShows
on readFile(unixPath)
set foo to (open for access (POSIX file unixPath))
set txt to (read foo for (get eof foo))
close access foo
return txt
end readFile
当我运行输出时,我得到了这个:
error "Can not change \"Game.of.Thrones-\\\"Game Of \" to type file." number -1700 from "Game.of.Thrones-\"Game Of " to file"
我的列表如下所示:Game.of.Thrones-“权力的游戏”和另外两行类似的行。