我要修改"文件.txt"的内容,按"要替换的内容.txt"中的行号来替换
要替换的内容.txt的内容为- 8,AOA7AAAQAACkijwAAgAAAAAAQAAAEAAAAAAQAAAQAAAAAAAAEAAAAAAAAAAAAAAA
- 5880,i9iDxASJXeyLReyFwHQKxwVkEW0AAQAAAItF7IP4B3cX/ySFFFhEAItNqOhAGwAA
- 5944,/9aFwHQFiV246wTGRecBi0XsUP8VaCBhAIpd54TbdC6NfYCDyf8zwPKu99FJg/kX
- 5950,hfZ1NYsN6BdtAI1V6I2FgP7//1KLVexQagBqAFFSx0XoAAEAAP8VBCBhAPfYG8BA
- 5981,AYrKOtN1DoPAAoPGAoTJddwzwOsFG8CD2P+FwHUJi0XsUOnCAgAAofgXbQCNtYD+
- 6253,XmSJDQAAAACDxBDDkJCQkGr/aBuXXwBkoQAAAABQZIklAAAAAIHsiAEAAKFkxWwA
- 6877,IGEAjU3ojZVM/v//UYtN5FJqAGoAUFHHRegAAQAA/9OLVeSL8PfeG/ZSRv8VaCBh
- 6904,DQAAAABfXluL5V3DiV3g6wSFwHRtagDof3wXAFDoy4oXAIPECOjQihcAiUXs20Xs
- 8090,/xWsJ2EAiJ4EAgAAi4YkAgAAPbiIAAAPjZsAAACLlsgBAAC/AQAAADPJO0oIcyCL
- 8115,BACLVhxqb1L/FawnYQCLRhxqAGhvFAAAaBEBAABQxob8AQAAAP8VuCdhAItN9GSJ
- 9979,RCQkEAAAAP8VBCBhAIXAD4XrAAAAjUQkOFDolUYVAIPEBI1MJBSNVCQcjUQkIFFS
- 10060,jUwkYMaEJAwDAAAG6I8H/f+LRCQcjYwkwAAAAFBR6A0pFQCDxAiFwA+ESAIAALI+
- 10107,AAAAK/CD/jwPhoAAAACLRCQYaglomRQAAGgRAQAAi0gcUf8VuCdhAItUJBRS/xVo
- 10116,YMaEJAwDAAAG6BL9/P+LRCQcjYwkwAAAAFBR6JAeFQCDxAiFwA+ESAIAALI+jXwk
- 10120,dRyEyXQUilgBiss6XgF1DoPAAoPGAoTJdeAzwOsFG8CD2P+FwHUYi1QkGFBomRQA
- 10123,WAGKyzpeAXUOg8ACg8YChMl14DPA6wUbwIPY/4XAdRmLRCQYagdomRQAAGgRAQAA
- 10128,M8DrBRvAg9j/hcB1DFCLRCRAUP8VDCBhAGoAi0wkHGiZFAAAaBEBAACLURxS/xW4
- 15717,AIlN3Il95GaJfeChCBFtAMZF/AE7x4vwdQW+DBFtALp0IGoAhdIPhPsAAAA79w+E
- 16357,0g+EAgEAAIX2D4T6AAAAuCx1agCFwA+E7QAAAFKNjXT////o6CT0/1aNTbTGRfwS
- 21736,dGVT6Jhg8/+FwHVbOX0IdQq4BAAAAOnQBgAAi0UEOXgwdESNTCQk6LSl/f+LTQSJ
- 21818,AF9eW4vlXcONlSj///9qMlJoEwQAAIvL6KcyDgCFwHUOUKFgH20AaIQfagBQ68GN
- 21823,M8DyrvfRSXUSiw1UH20AagBohB9qAOnk/v//jb18////g8n/M8DyrvfRSTiUDXv/
- 21832,i8iD+f90FY0E/wPPRo08gevTQOveikXvhMB0FosNVB9tAGoAaIQfagBRi03I6SD9
- 23263,oXARbQCFwA+E3AEAAKHoD20AhcB0BYlF7OsKx0Xs7A9tAItF7Is9+A9tAIX/dAWJ
- 33363,av9o6NpgAGShAAAAAFBkiSUAAAAAg+w0VleL+Y1MJBToyxcAAIuHqEkAAGgAAQAA
- 57969,JWxkKQoAAAAudGVzdGluZ2V4dAAiJSVzIiAvY2ggJWxkIC93ICVJNjRkAABJAEQA
复制代码 其中","前的为行号而 ","的为替换后的内容
直观的说就是
把"文件.txt"第8行的内容替换为AOA7AAAQAACkijwAAgAAAAAAQAAAEAAAAAAQAAAQAAAAAAAAEAAAAAAAAAAAAAAA
把"文件.txt"第5880行的内容替换为i9iDxASJXeyLReyFwHQKxwVkEW0AAQAAAItF7IP4B3cX/ySFFFhEAItNqOhAGwAA
把"文件.txt"第5944行的内容替换为/9aFwHQFiV246wTGRecBi0XsUP8VaCBhAIpd54TbdC6NfYCDyf8zwPKu99FJg/kX
把"文件.txt"第5950行的内容替换为hfZ1NYsN6BdtAI1V6I2FgP7//1KLVexQagBqAFFSx0XoAAEAAP8VBCBhAPfYG8BA
.......
要替换的文件有5M多,自己做了个批处理感觉替换速度太慢,求更快速的批处理或者第三方的批处理方便处理大文件- @echo off
- setlocal enabledelayedexpansion
- set hang=0
- set tiaoguo=0
- call :huoqu
- cd.>处理的后文件.txt
- for /f "delims=" %%a in (文件.txt) do (
- set /a hang=!hang!+1
- if "!hang!"=="!hanghao!" (
- echo.!neirong!>>处理的后文件.txt
- call :huoqu
- ) else (
- echo.%%a>>处理的后文件.txt"
- )
- )
- pause
- exit
-
- :huoqu
- for /f "tokens=1,2 delims=," %%a in ('more +!tiaoguo! 要替换的内容.txt') do (
- set /a tiaoguo=!tiaoguo!+1
- set hanghao=%%a
- set neirong=%%b
- goto :EOF
- )
复制代码 "文件.txt"和"要替换的内容.txt"下载地址
http://share.weiyun.com/c281813f4eecc89e2a71fe64030f1b0e |