我一直在使用 applescript 和 rsync 开发一个简单的自动备份实用程序,并且除了另外 1 个问题之外,一切正常,在启动脚本时,我希望能够选择多个硬盘驱动器进行备份(这工作),之后,我只允许选择 1 个备份驱动器,问题是,我希望所有选定的驱动器都驻留在备份驱动器上自己的文件夹中(请参阅随附的屏幕截图),但是我应该如何做到这一点有点迷失(我是新手到 applescript 和 rsync,通过大量研究才走到这一步,但现在卡住了)
这是我拥有的代码,所有驱动路径都在“源”变量中,我在 for 循环中对其进行迭代。
set sources to (choose folder with prompt "Select drives to back up" default location "Volumes" with multiple selections allowed)
set destination to (the POSIX path of (choose folder with prompt "Select destination volume" default location "Volumes"))
#for loop iterating all sources to backup
repeat with aliasPath in sources
set source to the POSIX path of aliasPath
set sciptsFinished to false
tell application "Terminal"
if not (exists window 1) then reopen
activate
do script "rsync --dry-run --archive -v --progress --exclude=\".*\" --delete --delete-during --stats --human-readable --human-readable " & quoted form of source & " " & quoted form of destination in window 1
delay 5 #give terminal time to activate
repeat while (window 1 is busy)
delay 1
end repeat
do script "osascript -e 'display notification \"RSYNC file changes calculated.\" with title \"RSYNC Backup\"'" in window 1
#mark scripts completed
set scriptsFinished to true
end tell
#wait for scripts to finish before proceeding
repeat while (scriptsFinished is false)
delay 2
end repeat
任何帮助将不胜感激(如果您对代码有意见,请随时启发我,因为我仍然是 applescript 的菜鸟)
提前致谢!