批处理中怎样删除子目录下的文件?

来源:百度知道 编辑:UC知道 时间:2024/06/24 13:05:13
要对某文件夹下的每个子目录(及子目录的子目录)执行如下代码:
del *.dsw
del Debug /q
rd Debug
应该怎样弄?
这个是我用来清理VC++在编译和调试的过程中产生的文件用的,全文如下
del *.plg
del *.ncb
del *.opt
del *.dsp
del *.dsw
del Debug /q
rd Debug

其中del Debug /q的作用是删除Debug目录下的所有文件.
Debug文件夹和*.cpp.*.plg...等是在同一个文件夹下的,我需要的只是.cpp,而要把VC所产生的其他文件全部删除.

copy con:1.bat
c:(看你自己是什么盘符)
cd debug
dir *.dsw
del *.dsw/a:r:h(确定再没有子目录)
del debug /q(这一句我没看明白你要表达的意思)
cd..
rd debug

rd/s debug
强制删除文件夹及其目录下的所有文件。