1、遍历某个文件夹及其子文件夹目录,删除全部名为CVS的目录:
进入CMD界面执行以下两句,第一句进入特定待查找的目录,第二句删除当前目录及子目录下全部名为CVS的文件夹
cd "E:\3_DSP"
for /R %s in (.,*) do rd /q /s %s\CVS
参考:http://blog.sina.com.cn/s/blog_517d1cb00100se0v.html
标签:
Syntax:
FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]
Description:
Walks the directory tree rooted at [drive:]path, executing the FOR statement in each directory of the tree.
Example:
@echo off
REM recursively print absolute path of sub-folders and files under drive D:
for /R "D:\" %%s in (.,*) do (
echo %%s
sleep 0.3
)
REM recursively print absolute path of only sub-folders under current folder
for /R %%s in (.) do (
echo %%s
sleep 0.3
)
REM recursively print absolute path of only files under current folder
for /R %%s in (*) do (
echo %%s
sleep 0.3
)
REM recursively print absolute path of files under current folder and sub-folders but only for those files with name matching pattern "list?.xul" (i.e. list0.xul or listA.xul).
for /R %%s in (list?.xul) do (
echo %%s
sleep 0.3
)
REM do the same with the above but without sleeping
for /R %%s in (list?.xul) do echo %%s
The above examples just perform echo command. However, you can do more complex commands as needed. For example, the following example is used to perform the following operations on all *.xul file under the current folder and sub-folders
@echo off
set FIREFOX_ROOT="C:\Program Files\Mozilla Firefox\"
set FIREFOX="firefox.exe"
for /R %%s in (*.xul) do (
start /D%FIREFOX_ROOT% FIREFOX -chrome %%s
start notepad %%s
sleep 5
taskkill /f /fi "imagename eq firefox.exe"
taskkill /f /fi "imagename eq notepad.exe"
)
2011年12月25日 13:21
(.,*)
.,后面那是个什么字符?
2012年8月03日 10:55
@fxz_abc: 可以把它复制到记事本中看,会看到那是个星号。网页显示不清楚。