#1 2016-02-14 12:36

alcestneige
Member
Registered: 2013-01-19
Posts: 28

Delete all files with file size lower than...

Hello,
Please is there a way to delete all files which have file size lower than 10MB?

I have a tons of different folders with sub-folders and I would like to use ReNamer to delete all unnecessary small files.

For removing of specific files I'm using something like this.

var
 ext:string;
 
begin
  ext := WideExtractFileExt(FileName);

  if (ext = '.jpg') then
  begin
     WideDeleteFile(FilePath); //delete the file
  end; 
end.

It will delete all .jpg files.
However I can't use it all the time as they are files with the same extension and with greater files size which have more importance as only an picture with some icon or logo.

I need to get rid of all the small files.

Thank you for your help.

Offline

#2 2016-02-14 21:44

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Re: Delete all files with file size lower than...

You need the WideFileSize function and minor modification of your script:

const
  FileSizeLimit = 10 * 1024 * 1024; // 10 Mb
var
  Ext: String;
begin
  Ext := WideExtractFileExt(FileName);
  if (Ext = '.jpg') then
    if WideFileSize(FilePath) < FileSizeLimit then
      WideDeleteFile(FilePath);
end.

Function reference: ReNamer:Pascal_Script:Functions

Note, ReNamer is not intended for cleaning your file system. You might want to find a tool designed for such tasks.

Offline

#3 2016-02-15 09:47

alcestneige
Member
Registered: 2013-01-19
Posts: 28

Re: Delete all files with file size lower than...

It works flawlessly, thank you so much!

I know that for file system there are other tools, but why when ReNamer can do everything and all in one package. And I love to play with the rules big_smile

Offline

Board footer

Powered by FluxBB