私はapplescriptとrsyncを使用して単純な自動化バックアップユーティリティに取り組んできましたが、スクリプトを開始するときに、バックアップする複数のハードドライブを選択できるようにしたい(これは機能します)その後、選択できるバックアップ ドライブは 1 つだけです。問題は、選択したすべてのドライブをバックアップ ドライブの独自のフォルダーに配置したいのですが (添付のスクリーンショットを参照)、これを行う方法が少しわかりません (初心者です)。 Applescript と rsync に接続し、多くの調査を行ってここまでたどり着きましたが、現在は行き詰まっています)
これは私が持っているコードです。すべてのドライブ パスは「sources」変数にあり、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 の新人なので、お気軽に教えてください)
前もって感謝します!