unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
LabeledEdit1: TLabeledEdit;
LabeledEdit2: TLabeledEdit;
Button1: TButton;
procedure FindAllFiles(
var FileList: TStringList; RootFolder:
string; Mask:
string = '
*.*'; Recurse: Boolean = True);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FindAllFiles(
var FileList: TStringList; RootFolder:
string; Mask:
string = '
*.*'; Recurse: Boolean = True);
var SR: TSearchRec;
begin
if AnsiLastChar(RootFolder)^ <> '
\'
then
RootFolder := RootFolder + '
\';
if Recurse
then
if FindFirst(RootFolder + '
*.*', faAnyFile, SR) = 0
then
try
repeat
if SR.Attr
and faDirectory = faDirectory
then
if (SR.
Name <> '
.')
and (SR.
Name <> '
..')
then
FindAllFiles(FileList, RootFolder + SR.
Name, Mask, Recurse);
until FindNext(SR) <> 0;
finally
FindClose(SR);
end;
if FindFirst(RootFolder + Mask, faAnyFile, SR) = 0
then
try
repeat
if SR.Attr
and faDirectory <> faDirectory
then FileList.Add(RootFolder + SR.
Name);
until FindNext(SR) <> 0;
finally
FindClose(SR);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
files, temp:TStringList;
i:integer;
begin
files:=TStringList.Create;
temp:=TStringList.Create;
FindAllFiles(files,ExtractFileDir(Application.ExeName));
for i:=0
to files.Count-1
do
temp.Add(StringReplace(files[i],LabeledEdit1.Text,LabeledEdit2.Text,[rfReplaceAll]));
for i:=0
to files.Count-1
do
RenameFile(files[i],temp[i]);
end;
end.