Delphi - Renomear arquivos utilizando o Find First Find Next
procedure TForm1.BitBtn1Click(Sender: TObject);
var
SearchRec:TSearchRec;
Result:Integer;
strFinal, strFinal2, Path: string;
begin
Path := 'C:\caminho\exemplo\';
Result:=FindFirst(Path +'*.xml*', faAnyFile, SearchRec);
while Result=0 do
begin
strFinal := (copy(SearchRec.Name,0,pos('-',SearchRec.Name))) + '.pdf';
strFinal2 := StringReplace(StrFinal,'-','',[rfReplaceAll]);
RenameFile(Path+SearchRec.Name, Path+strFinal2);
Result:=FindNext(SearchRec);
end;
end;
Comentários
Postar um comentário