Board logo

标题: [文本处理] [分享]批处理把小写字母改为大写字母 [打印本页]

作者: Batcher    时间: 2022-9-22 14:26     标题: [分享]批处理把小写字母改为大写字母

【问题描述】
批量处理小写英文带数字改为大写英文带数字

修改前:
a1b2c3
ddd
5e 6f

修改后:
A1B2C3
DDD
5E 6F
作者: Batcher    时间: 2022-9-22 14:27

【解决方案】

test_1.bat
  1. @echo off
  2. cd /d "%~dp0"
  3. setlocal enabledelayedexpansion
  4. (for /f "delims=" %%i in ('type "1.txt"') do (
  5.     set "StrRow=%%~nxi"
  6.     set "StrRow=%%~nxi"
  7.     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 (
  8.         set "StrRow=!StrRow:%%j=%%j!"
  9.     )
  10.     echo,!StrRow!
  11. ))>"1_Upcase.txt"
复制代码
类似的需求:批处理修改文件名字母大写小写转换
https://mp.weixin.qq.com/s/tPzWXXgS0QKt9Oo77_K03A
作者: Batcher    时间: 2022-9-22 14:48

test_2.bat
  1. ' 2>nul 3>nul&@echo off&cls
  2. '&start wscript.exe /nologo /e:vbs %0&exit /b
  3. Set objFSO = CreateObject("Scripting.FileSystemObject")
  4. Set objSrcFile = objFSO.OpenTextFile("1.txt",1,True)
  5. Set objDstFile = objFSO.OpenTextFile("1_Upcase2.txt",2,True)
  6. strOld = objSrcFile.ReadAll()
  7. strNew = UCase(strOld)
  8. objDstFile.Write strNew
复制代码

作者: Batcher    时间: 2022-9-22 15:04

test_3.bat
  1. @echo off
  2. powershell -c "Get-Content 1.txt | ForEach-Object {$_.ToUpper()} | Out-File 1_Upcase3.txt"
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2