I need to write a command in a .bat file that recursively deletes all the folders starting with a certain string. How may I achieve this ?
相关问题
- PHP Recursively File Folder Scan Sorted by Modific
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- Compile and build with single command line Java (L
- CosmosDB emulator can't start since port is al
- Recursively replace keys in an array
rm -rf -- "Directory name"
Ex : rm -rf -- "-2096378"
Above command will deletes the folders/directories starting with - or wildcard characters
How about:
This will work from the command prompt. Inside a batch file, you would have to double the
%
s, as usual:This is the complete answer you are looking for:
where obviously you need to replace
certain_string
with the string your folders start with.This deletes RECURSIVELY as you asked (I mean it goes throught all folders and subfolders).
Unfinished, I think. If you meant "Recursively go down a directory hierarchy to delete all folders starting with a certain string", then the following might suffice:
This will recurse into the directory tree, finding all folders starting with "abc", iterate over that list and removing each folder.
Maybe you need to wrap an
if exist
around therd
depending on the order in which directories are found and returned. In general, iterating over something and changing it at the same time is rarely a good idea but sometimes it works :-)