I'm looking to write a short batch script that will delete all files within a set of directories. More specifically, suppose I have the top directory "workspace" and it contains several directories beginning with the sting "project" (e.g. project-something, project-another). Then each of these "project" directories contain a "model" directory. I want to have the script empty each of these model directories.
我正在寻找一个简短的批处理脚本,它将删除一组目录中的所有文件。更具体地说,假设我有*目录“workspace”,它包含几个以sting“project”开头的目录(例如project-something,project-another)。然后,这些“项目”目录中的每一个都包含一个“模型”目录。我想让脚本清空每个模型目录。
I know this is doesn't work, but I looking for something along the lines of
我知道这不起作用,但我在找东西
del project*\model\*
But I know that the * after project will not select all directories starting with project then proceed into the model directories to clear them. What would be a correct way to go about doing this?
但是我知道项目之后的*将不会选择以project开头的所有目录,然后进入模型目录以清除它们。这样做的正确方法是什么?
Thank you for your time!
感谢您的时间!
1 个解决方案
#1
0
Put this into a .bat file and run.
将其放入.bat文件并运行。
@echo off
for /F "usebackq delims=" %%F in (`dir /ad /s /b model`) do (
del /s /q "%%F"
echo Removed "%%F"
)
pause
#1
0
Put this into a .bat file and run.
将其放入.bat文件并运行。
@echo off
for /F "usebackq delims=" %%F in (`dir /ad /s /b model`) do (
del /s /q "%%F"
echo Removed "%%F"
)
pause