fkjj.net
当前位置:首页 >> 如何用BAT批处理 将TXT文件中第N行的文字替换为另... >>

如何用BAT批处理 将TXT文件中第N行的文字替换为另...

@echo offfor /f "delims=" %%i in ('dir /s/b *.txt') do (for /f "delims=" %%a in ('type "%%~fi"') do (set "foo=%%a"call,set foo=%%foo:1234=4311%%call,echo/%%foo%%>>"%%~fi._")move "%%~fi._" "%%~fi")exit找到文件里数字1234 修改成 4321 保存 这样就可以了

你说的“空格空格空格9415”应该是“ 9415”(9415前有三个空格)吧.@echo offsetlocal enabledelayedexpansionset a=" 9415"call :sub %a%copy tmp.txt+2.txt 合并.txt /y>nulstart 合并.txtdel tmp.txt /fexit:subfor /f "tokens=1* delims=:" %%i in

@echo off title 文件名字符替换 mode con cols=60 lines=20::文件要是重名,会提示错误.setlocal EnableDelayedExpansion & color 0a:1 set a= set b= set c= cls&echo.set /p a= 请输入要被替换的字符:cls&echo.set /p b= 请输入替换“!a!”的

@echo off&setlocal enableDelayedExpansionset "r=hy.txt"for /f "tokens=2 delims=:" %%a in ('find /c /v "" "%r%"') do set m=%%afor /l %%a in (1,1,%m:~1%) do set #!random!!

1、把文件拖放到批处理图标上放开试试~ @echo off&set/a n=1&set/a m=1 setlocal enabledelayedexpansion for /f "tokens=1 delims=:" %%a in ('findstr/n .* %1')do set/a n=%%a for /f "tokens=1,* delims=:" %%i in ('findstr/n .* %1')do ( if !n!

set/p a=输入要增加的文字for /f "delims=" %%i in ('dir /b *.txt') do ( echo %a%>>%%i)代码跟2楼的有点相似,,但绝不是抄袭 顺便围观下1楼、

copy 文件1 文件2

@echo off setlocal enabledelayedexpansion set fn=C:\Program Files\file.txt set n=10(for /f "tokens=*" %%i in ('type "%fn%"') do ( set /a m+=1 if !m!==%n% (echo username=password) else echo %%i))>temp.txt move /y temp.txt "%fn%"

@echo off&setlocal enabledelayedexpansionset "fn="1.txt" "2.txt" "3.txt""(for %%i in (%fn%) do ( for /f "delims=" %%j in ('type %%i') do ( set /a m+=1 ) for /f "delims=" %%j in ('type %%i') do ( set /a n+=1 if !n! equ !m! ( echo;%

假设你要处理的文本文件名为1.txt@echo offsetlocal enabledelayedexpansion(for /f "tokens=*" %%i in (1.txt) do (set s=%%iif "!s:~-1,1!" neq "

网站首页 | 网站地图
All rights reserved Powered by www.fkjj.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com