作者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