标题: [文本处理] [分享]批处理把小写字母改为大写字母 [打印本页]
作者: Batcher 时间: 2022-9-22 14:26 标题: [分享]批处理把小写字母改为大写字母
【问题描述】
批量处理小写英文带数字改为大写英文带数字
修改前:
a1b2c3
ddd
5e 6f
修改后:
A1B2C3
DDD
5E 6F
作者: Batcher 时间: 2022-9-22 14:27
【解决方案】
test_1.bat- @echo off
- cd /d "%~dp0"
- setlocal enabledelayedexpansion
- (for /f "delims=" %%i in ('type "1.txt"') do (
- set "StrRow=%%~nxi"
- set "StrRow=%%~nxi"
- for %%j 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 "StrRow=!StrRow:%%j=%%j!"
- )
- echo,!StrRow!
- ))>"1_Upcase.txt"
复制代码
类似的需求:批处理修改文件名字母大写小写转换
https://mp.weixin.qq.com/s/tPzWXXgS0QKt9Oo77_K03A
作者: Batcher 时间: 2022-9-22 14:48
test_2.bat- ' 2>nul 3>nul&@echo off&cls
- '&start wscript.exe /nologo /e:vbs %0&exit /b
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objSrcFile = objFSO.OpenTextFile("1.txt",1,True)
- Set objDstFile = objFSO.OpenTextFile("1_Upcase2.txt",2,True)
- strOld = objSrcFile.ReadAll()
- strNew = UCase(strOld)
- objDstFile.Write strNew
复制代码
作者: Batcher 时间: 2022-9-22 15:04
test_3.bat- @echo off
- powershell -c "Get-Content 1.txt | ForEach-Object {$_.ToUpper()} | Out-File 1_Upcase3.txt"
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |