Windows batch file read text file and convert all to uppercase

后端 未结 1 1586
执笔经年
执笔经年 2020-12-19 20:05

I just simply want to replace all the text in the text file convert to uppercase.

For example of abc.txt

[Before conversion] First Name, Last Name, Full Name

相关标签:
1条回答
  • 2020-12-19 20:47

    The Batch file below do what you want, but if the file to convert is large this method is slow...

    @echo off
    setlocal EnableDelayedExpansion
    for /F "delims=" %%a in (%1) do (
       set "line=%%a"
       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 "line=!line:%%b=%%b!"
       )
       echo !line!
    )
    

    To use this program, place the name of the file in the first parameter. For example, if this Batch file is called TOUPPER.BAT:

    toupper abc.txt
    

    Note that this program eliminate empty lines and any exclamation mark existent in the file. These limitations may be fixed if needed, but the program becomes even slower...

    Antonio

    0 讨论(0)
提交回复
热议问题