2014-01-08 51 views
0

我是AppleScript的新用戶,我試圖解決腳本以將文件夾從我的mac備份到USB存儲器上的文件夾。使用AppleScript簡單備份USB存儲器上的文件夾

我開始創建這個腳本,但它不起作用。

tell application "Finder" 

    duplicate folder "/Users/alex/Desktop/test/" to "/Volumes/myusb/test/" replacing yes 

end tell 

感謝您的幫助。

回答

0

這應該工作:

set SourceFolder to POSIX file "/Users/alex/Desktop/test/" 
set TargetFolder to POSIX file "/Volumes/myusb/" 

tell application "Finder" 

    if exists SourceFolder then 

     try 

      duplicate SourceFolder to TargetFolder replacing yes 

     on error the error_message number the error_number 
      display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1 
     end try 

    end if 


end tell 

( 「POSIX文件」 是從 「StandardAdditions」)

相關問題