AppleScript和rsync-无法排除目录列表

时间:2018-11-17 23:53:16

标签: applescript rsync

我无法告诉rsync从同步过程中排除目录列表。我正在使用exclude-from命令向它提供文本文件,但似乎忽略了它。

这是我要在applescript中使用的代码:

set log_file to "/Users/x/Sync Test Folder/log.txt"
set exclude_file to "/Users/x/Sync Test Folder/log2.txt"
set target_folder to "/Users/x/Sync Test Folder"
set source_folder to "/Users/x/source_test/sub/" 

tell application "Terminal"
    activate
    set currentTab to do script "rsync" & " -avPhr " & "--include '*/' --exclude='*' --exclude-from=" & quoted form of exclude_file & " --log-file= " & quoted form of log_file & " " & quoted form of source_folder & " " & quoted form of target_folder & " >>" & quoted form of log_file
end tell

现在,我手动在log2.txt文件中输入要排除的目录名称,即/ directory_2 /,但这似乎不起作用。

有人可以帮忙指出什么地方出问题吗?

谢谢

1 个答案:

答案 0 :(得分:0)

我想出了答案的问题。事实证明,使用include或exclude / exclude-from语句的顺序很重要。因此,只需将exclude语句移至命令的开头,将include语句移至命令的末尾,一切将按预期进行。