[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
用for语句建立test1.txt、test2.txt和test3.txt三个文本文件。
@echo off
for %%a in (text1 text2 text3) do md %%a
pause

TOP

本帖最后由 holley 于 2018-8-16 16:53 编辑

回复 1# namejm
A1:
  1. @echo off
  2. set str=I love,bbs;bathome=net
  3. for %%i in (%str%) do echo %%i
  4. pause
复制代码
A2:
  1. @echo off
  2. set str=I love,bbs;bathome=net
  3. for %%i in (%str%) do if exist %%i echo %%i
  4. pause
复制代码
A2乱试出来的,有点想加个不存在的出错代码提示,结果发现可以得到最后一个匹配值...

TOP

  1. set str=I love,bbs;bathome=net
  2. for %%a in (%str%) do (echo %%a)
复制代码

TOP

回复 12# akiraakito


    这位老兄理解地好。谢谢

TOP

A1:
@echo off
echo 分隔符1:逗号
for %%i in (I,LOVE,BBS,BATHOME,NET) do echo %%i
echo ____________________________________________
echo 分隔符2:分号
for %%i in (I;LOVE;BBS;BATHOME;NET) do echo %%i
echo ____________________________________________
echo 分隔符3:等号
for %%i in (I=LOVE=BBS=BATHOME=NET) do echo %%i
echo ____________________________________________
echo 分隔符4:跳格键
for %%i in (I        LOVE        BBS        BATHOME        NET) do echo %%i
echo ____________________________________________
echo 分隔符5:空格
for %%i in (I LOVE BBS BATHOME NET) do echo %%i
echo ____________________________________________
echo 非分隔符:点
for %%i in (I.LOVE.BBS.BATHOME.NET) do echo %%i
echo ____________________________________________
pause

A2:
@echo off
set str=I,LOVE,BBS,BATHOME,NET
for %%i in (%str%) do (set a=%%i)
echo %a%
pause

TOP

回复 1# namejm


    A1:
  1. @echo off
  2. set "str=I love,bbs;bathome.net"
  3. for /f "tokens=1,2,3,4,5 delims=,;. " %%a in ("%str%") do (
  4. echo,%%a
  5. echo,%%b
  6. echo,%%c
  7. echo,%%d
  8. echo,%%e)
  9. pause>nul
复制代码
A2:
  1. @echo off
  2. set "str=I love,bbs;bathome.net"
  3. for /f "tokens=1,2,3,4,5 delims=,;. " %%a in ("%str%") do (
  4. echo,%%e)
  5. pause>nul
复制代码

TOP

A1:
  1. @echo off
  2. set str=I love,bbs;bathome=net
  3. for %%i in (%str%) do echo %%i
  4. pause
复制代码
A2:
  1. @echo off
  2. set str=I love,bbs;bathome=net
  3. for %%i in (%str%) do set var=%%i
  4. echo %var%
  5. pause
复制代码

TOP

回复 13# qpzlsn


   你设置了STR变量就可以直接引用了啊

TOP

题目更改后很简单。
A1:
@echo off
set str=I love,bbs;bathome=net
for %%I in (%str%) do  echo "%%I"
pause

A2:
@echo off
set str=I love,bbs;bathome=net
for %%i in (%str%) do if %%i==net echo %%i
pause



最初的题目(条件str=I love,bbs;bathhome.net),难度高。

TOP

题目更改后很简单。
A1:
@echo off
set str=I love,bbs;bathome=net
for %%I in (%str%) do  echo "%%I"
pause

A2:
@echo off
set str=I love,bbs;bathome=net
for %%i in (%str%) do if %%i==net echo %%i
pause



最初的题目(条件str=I love,bbs;bathhome.net),难度高。

TOP

好难。。。。

TOP

A1:
  1. @echo off
  2. set str=I love,bbs;bathome.net
  3. set str=%str:.= %
  4. for %%a in (%str%) do echo %%a
  5. pause
复制代码
A2:
  1. @echo off
  2. set str=I love,bbs;bathome.net
  3. set str=%str:.= %
  4. for %%a in (%str%) do if %%a == net;echo %%a
  5. pause
复制代码

TOP

A1:
  1. @echo off
  2. set str=I love,bbs;bathome=net
  3. for %%a in (%str%) do echo %%a
复制代码
A2:
  1. @echo off
  2. set str=I love,bbs;bathome=net
  3. for %%a in (%str=I love,bbs;bathome%) do echo %%a
复制代码

TOP

A1:
@echo off
set str=I love,bbs;bathome=net
for %%i in (%str%) do echo %%i
pause

A2:
@echo off
set str=I love,bbs;bathome=net
for %%i in (%str%) do (if %%i==net echo %%i)
pause
专注铸就成功!

TOP

本帖最后由 只是时间问题 于 2015-6-17 11:45 编辑
  1. @ECHO OFF
  2. echo.=-=-=-=-=A1=-=-=-=-=
  3. set str=I love,bbs;bathome.net
  4. for %%i in (%str%) do echo %%i
  5. echo.=-=-=-=-=A2=-=-=-=-=
  6. set str=I love,bbs;bathome.net
  7. set a=
  8. for %%i in (%str%) do (set a=%%i)
  9. echo %a%
复制代码

TOP

返回列表