要删除所有文件夹与模式匹配的当前目录 [英] To delete all folders in the current directory with pattern matching
本文介绍了要删除所有文件夹与模式匹配的当前目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要删除所有文件夹在开头当前目录下称富,接着按日期搜索
例如,我们有
I need to delete all the folders in current directory that starts with say "foo" followed by date
for example we have
- foo20120620
- foo20120513
- fooblabla
我可以成功地删除某条匹配当前日期搜索一个文件夹
例如:
I can successfully delete one folder that matches current date
example
set FOO_FOLDER=%CD%\foo%datetimef%
echo Y | rd /s/q %FOO_FOLDER%
但我不能够删除所有文件夹以foo开头。
But I'm not able to delete all the folders starting with foo.
我一直在想是这样
set OLD_PATTERN="%CD%\foo"
del %OLD_PATTERN%*
我用Google搜索,并试图按照已经被要求在这个论坛上的一些问题,但这些并不能帮助我很多。
I have googled and tried to follow some questions already being asked in this forum , but those doesn't help me a lot.
任何建议将是对我帮助很大。结果
必须在Windows上侧批脚本。
Any suggestion will be of great help to me.
must be in batch scripting on windows side.
推荐答案
您可以使用 FOR / D
命令。
for /d %%p in (foo*) do rd /s /q "%%p"
这篇关于要删除所有文件夹与模式匹配的当前目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文