使用AppleScript简单备份U盘上的文件夹

使用AppleScript简单备份U盘上的文件夹,applescript,backup,Applescript,Backup,我是AppleScript的新用户,我尝试解决一个脚本,将mac上的文件夹备份到U盘上的文件夹 我开始创建这个脚本,但它不起作用 tell application "Finder" duplicate folder "/Users/alex/Desktop/test/" to "/Volumes/myusb/test/" replacing yes end tell 谢谢您的帮助。这应该可以: set SourceFolder to POSIX file "/Users/alex/

我是AppleScript的新用户,我尝试解决一个脚本,将mac上的文件夹备份到U盘上的文件夹

我开始创建这个脚本,但它不起作用

tell application "Finder"

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

end tell
谢谢您的帮助。这应该可以:

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”)