我想写一个批处理文件来替换第一个逗号和第二个逗号之间的数字。
old.txt
time,in,out,all
06:00,1,0,1
06:15,12,0,1
06:30,6,1,8
new.txt
time,in,out,all
06:00,0,0,1
06:15,0,0,1
06:30,0,1,8
我该怎么做?
答案 0 :(得分:0)
根据实际的文件大小,字段和行的数量,这样的东西就足够了:
@Echo Off
Set "SrcFile=old.txt"
Set "DstFile=new.txt"
Set "RepChar=0"
Set "_="
(For /F "UseBackQ Tokens= 1,2* Delims=," %%A In (
"%SrcFile%") Do If Not Defined _ (Echo=%%A,%%B,%%C&Set "_=T") Else (
Echo=%%A,%RepChar%,%%C))>"%DstFile%"