使用Applescript(Mavericks)移动文件

时间:2014-03-20 02:23:35

标签: csv applescript

我已经检查了Stackoverflow中类似问题的先前答案,即使使用移动功能的最基本句子,似乎也存在问题。就我而言,我使用以下脚本。

set theFile to "Macintosh HD/Users/sergioguerra1/Downloads/Reporte General.csv"
set theFolder to "Macintosh HD/Users/sergioguerra1/Desktop/Detektor/Etapa II/"

tell application "Finder"
    move file theFile to folder theFolder with replacing
end tell 

我收到以下错误:

"错误" Finder收到错误:无法获取文件\" Macintosh HD / Users / sergioguerra1 / Downloads / Reporte General.csv \"。"编号-1728来自文件" Macintosh HD / Users / sergioguerra1 / Downloads / Reporte General.csv""

我稍微更改了脚本

tell application "Finder"
    move theFile to theFolder with replacing
end tell 

我得到了一个不同的错误

"错误" Finder收到错误:AppleEvent处理程序失败。"数字-10000"

这是一个非常简单的代码,但不起作用。谁能找到错误?这是小牛队的事吗?

1 个答案:

答案 0 :(得分:3)

在AppleScript中,您有不同类型的路径符号,并且您正在混合使用这两种路径符号。 HFS路径由文件和别名类使用。路径以卷名开头,并以“:”分隔。 Posix路径文件表示法由posix文件类使用。它总是从文件系统的根文件夹开始(其他系统安装到此文件系统中)并使用'/'作为它的分隔符。由于您的命令以move file开头,因此您已经指示文件路径表示法必须是HFS路径:

set theFile to "Macintosh HD:Users:sergioguerra1:Downloads:Reporte General.csv"
set theFolder to "Macintosh HD:Users:sergioguerra1:Desktop:Detektor:Etapa II"

tell application "Finder"
    move file theFile to folder theFolder with replacing
end tell