Hola cardanver.
Otra propuesta:
Código Delphi
[-]
procedure FormatTxtFile(const SourceName, TargetName: TFileName);
var
ori,des,aux: TStrings;
i,p : Integer;
h,m : string;
begin
ori:= TStringList.Create;
des:= TstringList.Create;
try
ori.LoadFromFile(SourceName);
for i:= 0 to ori.Count-1 do
begin
aux:= TStringList.Create;
try
ExtractStrings([' ',' '], [], PChar(ori[i]), aux);
aux[0]:= StringOfChar('0', 3-Length(aux[0])) + aux[0];
p:= Pos(':', aux[2]);
h:= Copy(aux[2], 1, p-1);
m:= Copy(aux[2], p+1, MaxInt);
h:= StringOfChar('0', 2-Length(h)) + h;
m:= StringOfChar('0', 2-Length(m)) + m;
aux[2]:= h + ':' + m;
finally
des.Add(Format('%s %s %s',[aux[0],aux[1],aux[2]]));
aux.Free;
end;
end;
des.SaveToFile(TargetName);
finally
ori.Free;
des.Free;
end;
end;
Ejemplo de uso:
Código Delphi
[-]
FormatTxtFile('C:\Pruebas\Original.txt', 'C:\Pruebas\Nuevo.txt');
Saludos