更新时间:2021-09-22 02:28:09
不,我不认识.
如果您出于某种原因(ACL,& c.)想要保留原始目录,而实际上却想清空它,则可以执行以下操作:
If you want to retain the original directory for some reason (ACLs, &c.), and instead really want to empty it, then you can do the following:
del /q destination\*
for /d %x in (destination\*) do @rd /s /q "%x"
这首先从目录中删除所有文件,然后以递归方式删除所有嵌套目录,但总体上保持顶层目录不变(内容除外).
This first removes all files from the directory, and then recursively removes all nested directories, but overall keeping the top-level directory as it is (except for its contents).
请注意,在批处理文件中,您需要将for
循环中的%
翻倍:
Note that within a batch file you need to double the %
within the for
loop:
del /q destination\*
for /d %%x in (destination\*) do @rd /s /q "%%x"