我使用rsync备份我的数据,并希望仅在一个目录(及其子目录)中排除特定的文件类型。例如,我有:
Sub test()
Dim wkb2 As Workbook
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim Arg1 As Range 'the range to sum
Dim Arg2 As Range 'criteria1 range`enter code here`
Dim Arg3 As Variant 'criteria1
Dim Arg4 As Range 'criteria2 range
Dim Arg5 As Variant 'criteria2
Dim i As Long
Dim k As Long 'Or if it is a worksheet name then as string
Dim j As Long
Set wkb2 = Workbooks("File2.xlsx")
'k = ''Set K variable here
Set ws2 = wkb2.Worksheets(k)
Set ws1 = ThisWorkbook.Worksheets("Sheet1") ' Change as appropriate
Set Arg1 = ws2.Range(Cells(i + 2, 6), Cells(i + 2, 6).End(xlDown).Offset(-1, 0))
Set Arg2 = ws2.Range(Cells(i + 2, 4), Cells(i + 2, 4).End(xlDown))
Set Arg4 = ws2.Range(Cells(i + 2, 5), Cells(i + 2, 5).End(xlDown))
Arg3 = ws1.Cells(j, 20)
Arg5 = ws1.Cells(j, 21)
ws1.Cells(j, 23).Value = Application.WorksheetFunction.SumIfs(Arg1, Arg2, Arg3, Arg4, Arg5)
End Sub
现在我想同步除 Folder2 及其子文件夹中 .tar 文件以外的所有文件。最后它应该是这样的:
$ ls Source/
Folder1/a.tar
Folder1/b.dat
Folder2/c.tar
Folder2/d.dat
Folder2/Subfolder3/e.tar
Folder2/Subfolder3/f.dat
Folder2/Subfolder3/g.pdf
有人知道怎么做吗?我玩$ ls Target/
Folder1/a.tar
Folder1/b.dat
Folder2/d.dat
Folder2/Subfolder3/f.dat
Folder2/Subfolder3/g.pdf
选项,但没有运气。
答案 0 :(得分:1)
rsync 手册说
INCLUDE/EXCLUDE PATTERN RULES
...
o use ’**’ to match anything, including slashes.
所以你可以做到
rsync -a --exclude='Folder2/**.tar' Source/ Target
请注意,这与 bash 的 globstar 选项不同,您可以使用Folder/**/*.tar
。