批处理for in do输出指定内容@echo offcd \workfor /f %%z in ('findstr /s /i /m "read=0" *.*') do (\x05for /f "tokens=1,* delims==" %%a in ('find "Ftd" ^< %%z') do (\x05\x05for /f "tokens=1,* delims==" %%c in ('find "inipath" ^< %%z') do (\x05\

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 14:36:43
批处理forindo输出指定内容@echooffcd\workfor/f%%zin(''findstr/s/i/m"read=0"*.*'')do(\x05for/f"tokens=1,*delims==

批处理for in do输出指定内容@echo offcd \workfor /f %%z in ('findstr /s /i /m "read=0" *.*') do (\x05for /f "tokens=1,* delims==" %%a in ('find "Ftd" ^< %%z') do (\x05\x05for /f "tokens=1,* delims==" %%c in ('find "inipath" ^< %%z') do (\x05\
批处理for in do输出指定内容
@echo off
cd \work
for /f %%z in ('findstr /s /i /m "read=0" *.*') do (
\x05for /f "tokens=1,* delims==" %%a in ('find "Ftd" ^< %%z') do (
\x05\x05for /f "tokens=1,* delims==" %%c in ('find "inipath" ^< %%z') do (
\x05\x05\x05for /f "tokens=1,* delims==" %%e in ('find "cam" ^< %%z') do (
\x05\x05\x05\x05for /f "tokens=1,* delims==" %%g in ('find "arjpath" ^< %%z') do (
\x05\x05\x05\x05echo Ftd= %v% inipath= %w% cam= %x% arjpath= %y%
\x05\x05\x05\x05)
\x05\x05\x05)
\x05\x05)
\x05)
)
按我的设想,findstr输出work目录下所有包含read=0的文件.用find取多个值以后用echo输出
结果,只有findstr输出的最后一个文件被echo输出,其余的都没有显示 结果类似
Ftd= 19854 inipath= v:\work\ddd\ cam= HP aeppath= arjpath
Ftd= 19854 inipath= v:\work\ddd\ cam= HP aeppath= arjpath
Ftd= 19854 inipath= v:\work\ddd\ cam= HP aeppath= arjpath
Ftd= 19854 inipath= v:\work\ddd\ cam= HP aeppath= arjpath
work目录下有4个子目录符合findstr的搜索条件
set v=%%b
\x05\x05\x05\x05set w=%%d
\x05\x05\x05\x05set x=%%f
\x05\x05\x05\x05set y=%%h
echo Ftd= %v% inipath= %w% cam= %x% arjpath= %y%
额 少贴了几行

批处理for in do输出指定内容@echo offcd \workfor /f %%z in ('findstr /s /i /m "read=0" *.*') do (\x05for /f "tokens=1,* delims==" %%a in ('find "Ftd" ^< %%z') do (\x05\x05for /f "tokens=1,* delims==" %%c in ('find "inipath" ^< %%z') do (\x05\
当不需要进行变量变换(加减取舍等)时就不要另设变量了,直接
echo Ftd= %%b inipath= %%d cam= %%f arjpath= %%h就行了
如果要赋给变量,则要设置变量延迟扩展setlocal enabledelayedexpansion
并用一对!号代一对%号将变量括起来用,如 !v!代替%v%