Windows批处理文件读取文本文件和所有转换为大写 [英] Windows batch file read text file and convert all to uppercase

查看:232
本文介绍了Windows批处理文件读取文本文件和所有转换为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是单纯的想替换文本文件中的所有文本转换为大写。

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

例如的abc.txt的

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

这是可能的?

推荐答案

下面的批处理文件做你想做的,但如果要转换的文件较大这种方法是缓慢的...

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!
)

要使用这个程序,将文件名中的第一个参数。例如,如果该批处理文件名为TOUPPER.BAT:

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...

安东尼奥

这篇关于Windows批处理文件读取文本文件和所有转换为大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆