3

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 Brad, Pitt, Brad Pitt

[After conversion] FIRST NAME, LAST NAME, FULL NAME BRAD, PITT, BRAD PITT

Is that possible??

Omi Chiba
  • 55
  • 1
  • 2
  • 7
  • 2
    Lookie here: http://benohead.com/batch-convert-to-uppercase/ – David Starkey Mar 26 '13 at 22:28
  • 1
    Please DON'T! Examples like that are the cause that many people thinks that Batch language is rudimentary and crude... – Aacini Mar 27 '13 at 02:21
  • @Aacini: I take your point well. +1 on your comment. Let's hope no one emulates the code cited. And ... batch language isn't rudimentary and crude? Really!? :) Umm ... yeah. It is. Sorry to speak the unwanted truth! :) – BaldEagle May 20 '16 at 02:04

1 Answers1

9

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

Aacini
  • 65,180
  • 12
  • 72
  • 108