有什麼快的辦法在一批文件的文件名的第二位加一個0
解决方案 »
- 在 控件 Edit1 的 OnKeyDown 事件 里怎么判断按下的是 Enter 键——————————在线等待!!!
- 急死了!!!!我用NMFTP下载文件,但是每次下载到114个文件就停止了,调试也不报错,请问如何解决?
- 急!!!我很迷惑,希望对数据库和通讯有经验的高手来畅谈一下
- 用TADOQuery是否可以一次执行两个Select语句,然后这两个语句的结果集合在一起显示在一个DBGrid上?
- 请教一个API函数!!怎样判断一个按钮是否可用(Enable)!
- 文件操作:我用Read函数读取一个数据文件,显示在Memo控件上:Memo1.Lines.Add (a)。但是读出来的数据是一个数据显示一行,我想由若干个
- D7+raize5.12 GroupBar问题
- 便宜分 怎么样在delphi上用OpenDialog和按钮来打开一个文档
- 100元解决打印问题,决不食言
- 一个特怪的事情,每次随机产生的都一样!!看里面代码:
- 请帮我来选选课程,谢谢!
- 请问如何让自己做的程序能够自动适应不同分辨率的屏幕呢? 请帮忙看看,在此谢谢了
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure renames(APath, Sourfile: string);
var
FSearchRec : TSearchRec;
FindResult : integer; s : WideString;
function IsDirNot(A : string) : boolean;
begin
Result := (a = '.') or (a = '..');
end;
begin try
FindResult := FindFirst(Apath+Sourfile,faDirectory,FSearchRec);
while FindResult = 0 do
begin
if ((FSearchRec.Attr and fadirectory) = faDirectory) then
begin
if not IsDirNot(FSearchRec.Name) then begin
s := FSearchRec.Name;
Insert('0',s, 2); //在第二位插入0 RenameFile(apath+FSearchRec.Name,apath+s);
renames(APath + FSearchRec.Name + '\',Sourfile);
end;
end else begin
s := FSearchRec.Name;
Insert('0',s, 2);
RenameFile(apath+FSearchRec.Name,apath+s);
end;
FindResult := FindNext(FSearchRec);
end;
finally
FindClose(FSearchRec);
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
renames('d:\sql\','*.*');
end;end.
用那個裡面的哪個工具呀。
你給我的代碼可以實現收集指定文件夾下面的所有指定後綴的文件集不。
procedure TForm1.Findds(AStrings: TStrings; APath, Sourfile: string);
var
FSearchRec : TSearchRec;
FindResult : integer;
TmpList:TStringList;
i : integer;
function IsDirNot(A : string) : boolean;
begin
Result := (a = '.') or (a = '..');
end;
begin
try
TmpList:=TStringList.Create;
TmpList.Clear;
FindResult := FindFirst(Apath+Sourfile,faDirectory,FSearchRec);
while FindResult = 0 do
begin
if ((FSearchRec.Attr and fadirectory) = faDirectory) then
begin
if not IsDirNot(FSearchRec.Name) then begin
tmplist.Add(apath+FSearchRec.Name); Findds(AStrings, APath + FSearchRec.Name + '\',Sourfile);
end;
end else tmplist.Add(apath+FSearchRec.Name);
FindResult := FindNext(FSearchRec);
end;
for i := 0 to TmpList.Count -1 do
AStrings.Add(TmpList.Strings[i]);
TmpList.Free;
finally
FindClose(FSearchRec);
end;
end;
2
3
@echo off
cd e:\temp\temp
for %%i in (*.*) do (
set LIST= %%i
set KKK=!LIST!
set m=!KKK:~1,1!0!KKK:~2!
ren !KKK! !m!
)
然后,进入命令行,执行:
cmd /v:on /c 1.bat
就可以了
------------------------------------------------------------------
win2k/xp的cmd拥有强大的功能,虽然不能与unix的shell相比,但要完成一般的文件/文本处理,足够了