D7遍历文件改名的问题
NC217 2017-11-05 06:39:24 function MakeFileList(Path,FileExt:string):TStringList ;
var
E1:integer;
sch:TSearchrec;
begin
E1:=0;
Result:=TStringlist.Create;
if rightStr(trim(Path), 1) <> '\' then
Path := trim(Path) + '\'
else
Path := trim(Path);
if not DirectoryExists(Path) then
begin
Result.Clear;
exit;
end;
if FindFirst(Path + '*', faAnyfile, sch) = 0 then
begin
repeat
Application.ProcessMessages;
if ((sch.Name = '.') or (sch.Name = '..')) then Continue;
if DirectoryExists(Path+sch.Name) then // 这个地方加上一个判断,可以区别子文件夹河当前文件夹的操作
begin
Result.AddStrings(MakeFileList(Path+sch.Name,FileExt));
end
else
begin
if (UpperCase(extractfileext(Path+sch.Name)) = UpperCase(FileExt)) or (FileExt='.*') then
Result.Add(Path+sch.Name);
end;
showmessage(sch.name); //显示每个文件夹里的文件名
renamefile(sch.name,concat(IntToStr(E1),'.elky') ); //改名字和后缀名
showmessage(sch.name);//不能正常显示修改后的名字
INC(E1);
until FindNext(sch) <> 0;
SysUtils.FindClose(sch);
end;
end;
不能正常修改文件夹里的文件名,请教大家我的代码要怎么写?