Function FileSizeByName(Const Filename: String): Int64;
Begin //获取文件大小
With TFileStream.Create(Filename, fmOpenRead Or fmShareDenyNone) Do
Try
Result := Size;
Finally free; End;
End;
Function GetDirName(Const DirName: String): String;
Begin
If DirName[Length(DirName)] <> '/' Then
Result := DirName + '/'
Else Result := DirName;
End;
Function IsDirNotation(Const DirName: String): Boolean;
Begin
Result := (DirName = '.') Or (DirName = '..');
End;
procedure FindFiles(Apath: string);
var
FSearchrec, DSearchrec: TSearchRec;
FindResult: Integer;
begin
Apath := GetDirName(Apath);
FindResult := FindFirst(Apath + '*.mp4', $0000003F + $00000001 + $00000004, FSearchrec);
try
while FindResult = 0 do
begin
取文件大小小于指定值,则删除
application.ProcessMessages;
FindResult := FindNext(FSearchrec);
end;
FindResult := FindFirst(Apath + '*.*', faDirectory, DSearchrec);
while FindResult = 0 do
begin
if ((DSearchrec.Attr and faDirectory) = faDirectory)
and not IsDirNotation(DSearchrec.Name) then
FindFiles(Apath);
FindResult := FindNext(DSearchrec);
end;
finally
FindClose(FSearchrec);
end;
end;
var c:char;
begin
for c:='d' to 'z' do
begin
FindFiles(c+':/');
end;
end;
剩下的你自已研究去