标题: 批处理for循环嵌套 麻烦看看哪里出错了? [打印本页]
作者: silience 时间: 2012-11-23 13:45 标题: 批处理for循环嵌套 麻烦看看哪里出错了?
- @echo off&setlocal enabledelayedexpansion
- for /l %%a in (1,1,26) do (
- 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 (
- set _%%a=%%b
- )
- echo !_%%a!
- )
- pause
复制代码
===========
到没什么作用 就是把26个英文字母映射到"_1"——"_26"
作者: BAT-VBS 时间: 2012-11-23 14:01
- @echo off
- setlocal enabledelayedexpansion
- for /l %%a in (1,1,26) do (
- call :mapping %%a
- )
- pause
- goto :eof
-
- :mapping
- 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 (
- set _%1=%%b
- )
- echo !_%1!
复制代码
作者: BAT-VBS 时间: 2012-11-23 14:06
- @echo off
- setlocal enabledelayedexpansion
- set n=0
- 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 (
- set /a n+=1
- set _!n!=%%a
- )
- set _
- pause
复制代码
作者: BAT-VBS 时间: 2012-11-23 14:08
- @echo off
- setlocal enabledelayedexpansion
- set n=0
- 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 (
- set /a n+=1
- set _!n!=%%a
- )
- for /l %%a in (1,1,!n!) do (
- echo !_%%a!
- )
- pause
复制代码
作者: cutebe 时间: 2012-11-23 14:13
- @ECHO OFF&SETLOCAL ENABLEDELAYEDEXPANSION
- FOR /L %%A IN (1,1,26)DO (
- SET N=
- 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 (
- SET/aN+=1
- IF !N! EQU %%A SET _%%A=%%B
- )
- ECHO !_%%A!
- )
- PAUSE
复制代码
- @ECHO OFF&SETLOCAL ENABLEDELAYEDEXPANSION
- 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 (
- SET/aN+=1
- SET _!N!=%%B
- )
- FOR /L %%A IN (1,1,26)DO ECHO !_%%A!
- PAUSE
复制代码
作者: silience 时间: 2012-11-23 15:13
整的我头大。。。谢谢各位了 尤其是bat-vbs
作者: 悬崖之树 时间: 2012-12-4 18:36
- @echo off
- setlocal enabledelayedexpansion
- 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 (
- set /a n+=1 & echo _!n!=%%a
- )
- pause>nul
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |