Loop through ASCII codes in batch file

后端 未结 5 1935
囚心锁ツ
囚心锁ツ 2021-01-04 17:46

How do I loop through ASCII values (here, alphabets) and work on them?

I want to echo A to Z without having to type every character manually like for %%J in (

5条回答
  •  北荒
    北荒 (楼主)
    2021-01-04 18:42

    In Vbscript, you can do something like this :

    For i = 65 To 90
        Car = Car & Chr(i) & vbTab
    Next
    wscript.echo Car
    

    And you can generate it with a batch file like this :

    @echo off
    Call :vbs
    Pause
    exit /b
    
    :vbs
    (
        echo For i = 65 To 90
        echo    Car = Car ^& Chr(i^) ^& vbTab
        echo Next
        echo wscript.echo Car
    )>"%tmp%\%~n0.vbs"
    Cscript /NoLogo "%tmp%\%~n0.vbs"
    

提交回复
热议问题