作者menasy (yes)
看板EZsoft
标题recursive delete using a batch file on wind …
时间Wed Dec 19 12:03:37 2007
※ [本文转录自 Windows 看板]
作者: menasy (yes) 看板: Windows
标题: recursive delete using a batch file on windows-XP
时间: Mon Nov 5 00:27:59 2007
I am trying to write a batch file which would recursively delete folders with
a specific name inside a tree. i am just not able to do that. Please help me.
thanks for your help in advance
This will do the trick:
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q %%G
If you're thinking WTF?:
DIR /B /AD /S *.svn*
lists all files that are named ".svn"
/B makes the output "bare" with nothing but the file name
/AD only lists directories
/S recurses subdirectories to include their contents if they match the
listing criteria
RMDIR /S /Q [path/name]
deletes the directory [path/dir] and all of it's children
FOR /F processes each item (in this case directories) in the set IN
('[command]') by executing the DO [command]
%%G is a parameter, which in this example is a directory name
"tokens=*" says that all the characters output in a line (i.e. by the dir
command) are assigned to the parameter %%G
See the Microsoft Command Line Reference for more on FOR:
--
[骡子]眼睛被黑布遮住了
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.121.64.121
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 210.59.117.99