type TForm1=class(TForm) ListView1:TListView; ListView2:TListView; Button1:TButton; Edit1:TEdit; Edit2:TEdit; Button2:TButton; Button3:TButton; Edit3:TEdit; Button4:TButton; procedureButton1Click(Sender:TObject); procedureListView2Click(Sender:TObject); procedureFormShow(Sender:TObject); procedureButton2Click(Sender:TObject); procedureButton3Click(Sender:TObject); private { Private declarations } public { Public declarations } end;
var Form1:TForm1;
implementation
{$R *.dfm} usesStrUtils;
functionAddSelItems(listview1:TListView;ListView2:TListView):Boolean; var s:string; I,j:Integer; begin Result:=False; iflistview1.Selected=nilthenexit;
fori:=0tolistview1.items.count-1do begin j:=ListView2.Items.Count; iflistview1.items[i].selectedthen
withListView2.Items.Adddo begin Caption:=IntToStr(j); SubItems.add(listView1.Items[i].Caption); SubItems.add(‘FileName2‘); end; end; Result:=True; end;
procedureTForm1.Button1Click(Sender:TObject); begin ListView1.SelectAll; AddSelItems(ListView1,ListVIew2); end;
var ID,FileName,NewName:string; procedureTForm1.Button2Click(Sender:TObject); var i:Integer; begin fori:=0toListView2.Items.Count-1do withListView2do begin ID:=Items[i].Caption; FileName:=Items[i].SubItems.Strings[0]; Items[i].SubItems.Strings[1]:=StringReplace(FileName,Edit1.Text,Edit2.Text,[rfReplaceAll]); end; end;
procedureTForm1.ListView2Click(Sender:TObject); begin iflistview2.Selected=nilthenexit;
procedureTForm1.FormShow(Sender:TObject); begin ListView1.SelectAll; AddSelItems(ListView1,ListVIew2); Button2.Click; end;
procedureTForm1.Button3Click(Sender:TObject); var i:Integer; LStr,RStr:string; begin LStr:=LeftStr(Edit3.Text,Pos(‘*‘,Edit3.Text)-1); RStr:=RightStr(Edit3.Text,Length(Edit3.text)-Pos(‘*‘,Edit3.Text)); fori:=0toListView2.Items.Count-1do withListView2do begin ID:=Items[i].Caption; FileName:=Items[i].SubItems.Strings[0]; Items[i].SubItems.Strings[1]:=Format(‘%s%s%s‘,[LStr,FileName,RStr]); end; end;