批处理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/11/27 13:32:32
批处理for in do输出指定内容@echo offcd \workfor /f %%z in ('findstr /s /i /m
xNA_e$hIۀU>iK.+Z؊Zl*i"|2;˕3;[)izdϜ9s,Qxo^ĽJd$*Fs'.H*[8ǒgRAkF Nѳv/W4dPBCid JAWtd܊)I9G!$J~tMhӐIXIɾp=yZ)iG 3%]p= NGN|Kgr".!QY80f[!v-VRIrEߚ7M2N-ƚVY$jTZC6EZY1J%";naL8X*K\(6. NoiXRow05׍~^UON! Bp-}}DOO$0!;@X]7p)iQgzmeqrnzh #Q5H_MYXAqeWV  |gTxd}8C)/'IfaqV

批处理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%