Batch - Converting variable to uppercase

前端 未结 8 1711
一向
一向 2020-12-02 01:39

How would I go about changing the destl variable to uppercase before it is used. I assume some sort of character swap, however I couldn\'t get it working. C

8条回答
  •  自闭症患者
    2020-12-02 02:39

    This is probably the fastest way to convert string to upper case using batch file - it uses a macro ,it stores only the upper case letters in the loop using the way of how batch replaces strings and stores the produced string in a variable called result:

    @echo off
    
    set UpperCaseMacro=for /L %%n in (1 1 2) do if %%n==2 (for %%# 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 "result=!result:%%#=%%#!") else setlocal enableDelayedExpansion ^& set result=
    
    set "string=SOme STrinG WiTH lowerCAse letterS and UPCase leTTErs"
    %UpperCaseMacro%%string%
    
    echo %result%
    

提交回复
热议问题