慕田峪7331174
procedure TForm1.Button1Click(Sender: TObject);varoritext,aimtext:TextFile;s,str:string;str1:string[5];i,m,n:integer;begini:=1;assignfile(oritext,'D:\aa.txt');//源文件reset(oritext);//只读方式打开assignfile(aimtext,'D:\bb.txt');//目标文件Rewrite(aimtext);{追加方式打开。也可以用Rewrite(aimtext),这是创建一个新文件(对于一个已存在的文件,此操作将使原文件被覆盖)。}trywhile not eof(oritext) do//循环读取文本beginreadln(oritext,s);str:=copy(s,3,4)+'/'+copy(s,7,2)+'/'+copy(s,9,2)+' '+copy(s,11,2)+':'+copy(s,13,2)+':00 '+copy(s,16,10)+' 001 00 1 ';m:=length(inttostr(i));//判断i为字符串时的长度,决定str1中0的个数for n:=1 to 5-m dostr1:=str1+'0';str:=str+str1+inttostr(i);str1:='';i:=i+1;writeln(aimtext,str);end;finallyclosefile(oritext);closefile(aimtext);end;end;运行正常,结果为:2007/06/26 18:59:00 0010165059 001 00 1 000012007/06/26 18:59:00 0010173847 001 00 1 000022007/06/26 18:59:00 0010185451 001 00 1 000032007/06/26 18:59:00 0010112243 001 00 1 000042007/06/26 18:59:00 0010165059 001 00 1 000052007/06/26 18:59:00 0010173847 001 00 1 000062007/06/26 18:59:00 0010185451 001 00 1 000072007/06/26 18:59:00 0010112243 001 00 1 000082007/06/26 18:59:00 0010165059 001 00 1 000092007/06/26 18:59:00 0010173847 001 00 1 000102007/06/26 18:59:00 0010185451 001 00 1 000112007/06/26 18:59:00 0010112243 001 00 1 00012