我想创建一个批处理文件,删除或删除文件夹 C:\temp\root\students\type1
、其子文件夹和所有文件。
我拥有的文件夹和文件如下:
C:\temp
C:\temp\root
C:\temp\root\students
C:\temp\root\tutors
C:\temp\root\students\type1
C:\temp\root\students\type2
C:\temp\root\tutors\type1
C:\temp\root\tutors\type2
C:\temp\root\students\type1\details.txt
C:\temp\root\students\type1\assignment1
C:\temp\root\students\type1\assignment1\results.txt
在批处理文件中指定文件夹C:\temp\root\students\type1\assignment1
。
我想向上移动一个文件夹/目录并删除或移除批处理文件 (test.bat) 中的 C:\temp\root\students\type1
。
请帮我解决这个问题。
最佳答案
使用这个:
rd /s /q C:\temp\root\students\type1
它将递归地删除文件和文件夹,小心,没有提示。它是旧的 deltree 的替代品。最好的。
编辑:在记事本中,使用以下内容创建 mygoodbatch.bat:
md C:\temp
md C:\temp\root
md C:\temp\root\students
md C:\temp\root\tutors
md C:\temp\root\students\type1
md C:\temp\root\students\type2
md C:\temp\root\tutors\type1
md C:\temp\root\tutors\type2
md C:\temp\root\students\type1\details.txt
md C:\temp\root\students\type1\assignment1
md C:\temp\root\students\type1\assignment1\results.txt
rd /s /q C:\temp\root\students\type1
(md 是 make dir dos 命令,因此以它开头的所有行都在创建文件夹 - 最后一行是删除 4AA 级的行)
将此批处理保存在磁盘根目录上,然后运行它。我真的希望这就是你想要的。我还不明白的是:你正在创建一个目录结构,同时排除 4AA 级......是这样吗?
关于windows - 如何使用批处理文件删除父文件夹中的特定子文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38448540/