我想在仍然执行清除的同时排除特定文件被删除。特定文件位于源中不存在的子目录中。
来源:
folder1\
file1.txt
Run Code Online (Sandbox Code Playgroud)
目的地:
folder1\
file1.txt
folder2\
dontdelete.txt
delete.txt
Run Code Online (Sandbox Code Playgroud)
如果我使用:
Robocopy C:\Source C:\Destination /e /purge /xf dontdelete.txt
Run Code Online (Sandbox Code Playgroud)
然后 Robocopy 将删除包含该文件的 folder2\,因此本质上仍然删除 dontdelete.txt 文件。
Source : C:\Source\
Dest : C:\Destination\
Files : *.*
Exc Files : dontdelete.txt
Options : *.* /V /L /S /E /DCOPY:DA /COPY:DAT /PURGE /R:1000000 /W:30
----------------------------------------------------------------------------
0 C:\Source\
1 C:\Source\folder1\
*EXTRA Dir -1 C:\Destination\folder1\folder2\
*EXTRA File 0 delete.txt
*EXTRA File 0 dontdelete.txt
same 0 file1.txt
Run Code Online (Sandbox Code Playgroud)
如果我使用:
Robocopy C:\Source C:\Destination /e /purge /xd folder2 /xf dontdelete.txt
Run Code Online (Sandbox Code Playgroud)
然后 …
robocopy ×1