- If no directory specification is specified after /R then thecurrent directory is assumed.
- If set is just a single period (.) character then it will justenumerate the directory tree.
- If set is just a single asterisk (*) character then it willjust enumerate the files.
- If set is a single period (.) character followed by a singleasterisk (*) character then it will enumerate the sub-foldersfirstly and then files under the sub-folder recursively.
- If set is a single asterisk (*) character followedby
a single period (.) characterthen it will enumerate the files firstly then the sub-folderrecursively. - Wildcards characters asterisk(*) and
period(.) can be repeated and the loop will also repeatedappropriately. - Question mark(?) is also supported and usually used to filterinterested files or sub-folders under specified folder or thecurrent folder.
REM recursivelyprint
for /R %%s in (list?.xul) do(
)
REM do the same with the above butwithout sleeping
for /R %%s in (list?.xul) do echo%%s
The above examples just perform echo command. However, you cando more complex commands as needed. For example, the followingexample is used to perform the following operations on all *.xulfile under the current folder and sub-folders
- open Firefox with *.xul file
- open *.xul files with notepad
- sleep for 5 seconds
- forcibly kill firefox and notepad
@echo off
set FIREFOX_ROOT="C:\ProgramFiles\Mozilla Firefox\"
set FIREFOX="firefox.exe"
for /R %%s in (*.xul) do (
)
flvtool2.exe给某文件夹中flv文件批量插入关键帧
@echo off
for /R "H:\topntweb\topnt\topnt\" %%s in (*.flv) do (
"H:\topntweb\topnt\topnt\FilesList\Exe\VideoTools\flvtool2.exe" -U %%s
)
pause