[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

批处理for循环嵌套 麻烦看看哪里出错了?

  1. @echo off&setlocal enabledelayedexpansion
  2. for /l %%a in (1,1,26) do (
  3.     for /f "tokens=%%a" %%b in ("a b c d e f g h i j k l m n o p q r s t u v w x y z") do (
  4.        set _%%a=%%b
  5.     )
  6.   echo !_%%a!
  7. )
  8. pause
复制代码
===========
到没什么作用 就是把26个英文字母映射到"_1"——"_26"

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for /l %%a in (1,1,26) do (
  4.     call :mapping %%a
  5. )
  6. pause
  7. goto :eof
  8. :mapping
  9. for /f "tokens=%1" %%b in ("a b c d e f g h i j k l m n o p q r s t u v w x y z") do (
  10.    set _%1=%%b
  11. )
  12. echo !_%1!
复制代码

TOP

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set n=0
  4. for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
  5.     set /a n+=1
  6.     set _!n!=%%a
  7. )
  8. set _
  9. pause
复制代码

TOP

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set n=0
  4. for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
  5.     set /a n+=1
  6.     set _!n!=%%a
  7. )
  8. for /l %%a in (1,1,!n!) do (
  9.     echo !_%%a!
  10. )
  11. pause
复制代码

TOP

  1. @ECHO OFF&SETLOCAL ENABLEDELAYEDEXPANSION
  2. FOR /L %%A IN (1,1,26)DO (
  3.  SET N=
  4.  FOR %%B IN (a b c d e f g h i j k l m n o p q r s t u v w x y z)DO (
  5.   SET/aN+=1
  6.   IF !N! EQU %%A SET _%%A=%%B
  7.  )
  8.  ECHO !_%%A!
  9. )
  10. PAUSE
复制代码
  1. @ECHO OFF&SETLOCAL ENABLEDELAYEDEXPANSION
  2. FOR %%B IN (a b c d e f g h i j k l m n o p q r s t u v w x y z)DO (
  3.  SET/aN+=1
  4.  SET _!N!=%%B
  5. )
  6. FOR /L %%A IN (1,1,26)DO ECHO !_%%A!
  7. PAUSE
复制代码
如无特别说明,代码测试环境均为 XP SP3

TOP

整的我头大。。。谢谢各位了 尤其是bat-vbs

TOP

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
  4.    set /a n+=1 & echo _!n!=%%a
  5. )
  6. pause>nul
复制代码
时光荏苒||新陈代谢&&涛声依旧||本性难移

TOP

返回列表