2012-12-27 45 views
3

我只是想將圖像從一個文件夾移動到其他,替換一個是已經在那裏:在Finder中移動文件使用AppleScript

tell application "Finder" 
     copy file "/Users/xx/Documents/img.jpg" to folder "/Users/xx/Documents/State" 
    end tell 

當我運行它,我得到一個錯誤信息說

Finder got an error: Can’t set folder [path] to file [path]"."number -10006 from folder [path]

請幫幫我!

回答

5

嘗試:

tell application "Finder" 
    duplicate POSIX file "/Users/xx/Documents/img.jpg" to POSIX file "/Users/xx/Documents/State" with replacing 
end tell 

或者

tell application "Finder" 
    move POSIX file "/Users/xx/Documents/img.jpg" to POSIX file "/Users/xx/Documents/State" with replacing 
end tell 
2

由於@adayzdone筆記,因爲你使用的是Posix樣式的路徑沒有宣佈它出現的錯誤。

另一種方法是使用冒號分隔的HFS路徑,像這樣:

move file "Macintosh HD:Users:xx:Documents:img.jpg" ¬ 
to "Macintosh HD:Users:xx:Documents:State:" with replacing 

不同,需要包括整個事情冒號分隔的路徑,包括卷名(我假設這裏的Macintosh HD ),否則會拋出我們的好友錯誤10,006。

相關問題