我使用以下代码复制整个文件夹:
set source_folder to POSIX path of (choose folder)
set target_folder to POSIX path of (choose folder)
try
do shell script "rsync -rlpta --stats " & source_folder & " " & target_folder)
on error
display alert "This script uses rsync and does not work if there are spaces in the folder names!"
end try
有没有办法捕获返回的统计数据" - stats"用于显示或作为文本,例如日志记录。
答案 0 :(得分:0)
只需将do shell脚本命令分配给变量即可捕获从命令返回的值。此外,在传递变量以执行shell脚本时,应始终使用“引用形式的x”。
set source_folder to POSIX path of (choose folder)
set target_folder to POSIX path of (choose folder)
try
set statResult to do shell script "rsync -rlpta --stats " & quoted form of source_folder & " " & quoted form of target_folder
return statResult
on error err
display alert err
end try