标题: [文本处理] 批处理怎么让txt里的文本大写转换成小写 [打印本页]
作者: Roxx 时间: 2024-3-4 12:11 标题: 批处理怎么让txt里的文本大写转换成小写
我有一个文本文档 里面全是邮箱账号
AbcdEfgh3211@hot.com----AbcDef1231
AbcdEfgh3212@hot.com----AbcDef1232
AbcdEfgh3213@hot.com----AbcDef1233
AbcdEfgh3214@hot.com----AbcDef1234
AbcdEfgh3215@hot.com----AbcDef1235
批处理怎么写只让账号大写转换成小写 密码不动 (注:账号长度不一样 一样的就是账号密码中间用----分隔开来了)
作者: 77七 时间: 2024-3-4 12:57
- @echo off
- rem 批处理和文本全部保存为ansi编码格式
-
- set input=1.txt
- set output=2.txt
-
- cd /d "%~dp0"
- (for /f "useback delims=" %%a in ("%input%") do (
- set str=%%a
- setlocal enabledelayedexpansion
- for /f "tokens=1*" %%x in ("!str:----= !") do (
- endlocal
- set str2=%%x
- set str3=%%y
- setlocal enabledelayedexpansion
- for %%i 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 "str2=!str2:%%i=%%i!"
- )
- echo !str2!----!str3!
- endlocal
- )
- ))>"%output%"
- pause
复制代码
作者: ppll2030 时间: 2024-3-4 14:03
本帖最后由 ppll2030 于 2024-3-4 14:14 编辑
回复 1# Roxx
账号密码保存为1.txt,编码格式为ANSI
代码保存为bat文件,编码格式为ANSI
运行结果会生成新文件1new.txt- @echo off
- echo str = WScript.Arguments(0) >>lc.vbs
- echo wscript.echo LCase(str)>>lc.vbs
- for /f "tokens=1*delims=@" %%i in (1.txt) do (
- for /f %%a in ('cscript //nologo lc.vbs "%%i"') do (
- echo %%a@%%j>>1new.txt
- )
- )
- del /q lc.vbs
复制代码
作者: hfxiang 时间: 2024-3-6 14:36
回复 1# Roxx
用第3方工具gawk( http://bcn.bathome.net/tool/4.1.0/gawk.exe )实现方式如下:- gawk -F"----" -v"OFS=----" "$1=tolower($1)" 1.txt>2.txt
复制代码
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |