我正在尝试制作一个在文件中写入文本然后将其复制到其他地方的脚本。我明白了:
tell application "Finder" to get folder of (path to me) as Unicode text
set workingDir to POSIX path of result
set theFile to workingDir & "file.txt"
set theText to "Some text..."
set theFileReference to open for access theFile with write permission
write theText to theFileReference
close access theFileReference
tell application "Finder" to duplicate theFile to "Macintosh HD:Applications:Microsoft Office 2011:Office:Startup:Word:" with replacing
但我总是得到错误:
error "Finder got an error: Can’t make \"/Users/ME/Documents/file.txt\" into type item."
最奇怪的是,我在上面做了一个重复的工作……但它基本上是一样的。
我从 Applescript 开始,所以我不会感到惊讶,这是一个愚蠢的小细节......所以任何线索都值得赞赏!