BAT脚本将小写单词转换成大写
时间: 2023-11-04 12:04:17 浏览: 167
可以使用以下BAT脚本将字符串中的小写单词全部转换成大写字母:
```
@echo off
set /p str="请输入一个字符串: "
set str=%str:~0,32767%
set str=%str:~0,32767%
set str=%str: = %
set str=%str:a=A%
set str=%str:b=B%
set str=%str:c=C%
set str=%str:d=D%
set str=%str:e=E%
set str=%str:f=F%
set str=%str:g=G%
set str=%str:h=H%
set str=%str:i=I%
set str=%str:j=J%
set str=%str:k=K%
set str=%str:l=L%
set str=%str:m=M%
set str=%str:n=N%
set str=%str:o=O%
set str=%str:p=P%
set str=%str:q=Q%
set str=%str:r=R%
set str=%str:s=S%
set str=%str:t=T%
set str=%str:u=U%
set str=%str:v=V%
set str=%str:w=W%
set str=%str:x=X%
set str=%str:y=Y%
set str=%str:z=Z%
setlocal enabledelayedexpansion
set "output="
for %%a in (%str%) do (
set "word=%%a"
set "first=!word:~0,1!"
set "rest=!word:~1!"
set "first=!first!"
set "rest=!rest!"
set "output=!output! !first!!rest!"
)
echo %output:~1%
```
运行这个脚本后,会要求你输入一个字符串,然后将字符串中的所有小写单词转换成大写字母后输出。注意,脚本会将字符串中的空格作为单词的分隔符。
阅读全文