• Delold source code

    From Nick Andre@618:500/24 to All on Wednesday, July 26, 2023 17:43:21
    Delold is a Freepascal program which deletes all but the X oldest file.

    In heavy use here for Fido ZC1 stuff... enjoy.

    Should be able to recompile for non-Windows and yes I'm sure theres plenty of room for improvement... This was written in one sitting after a few beers.

    program delold;
    uses dos;

    var dirinfo : SearchRec;
    count,newest : longint;

    procedure Eraseit;
    var f : file;
    begin
    writeln('Erasing '+dirinfo.name);assign(f,dirinfo.name);erase(f);
    end;

    begin
    count:=0;
    writeln('Delold 1.0/Win32 Copyright (c) by Nick J. Andre, Ltd.');
    writeln;
    if paramstr(1)>'' then
    begin
    findfirst(paramstr(1),archive,dirinfo);
    if DOSerror=0 then begin count:=count+1;newest:=dirinfo.Time;end;
    while (DOSerror=0) do
    begin
    findnext(dirinfo);
    count:=count+1;
    if dirinfo.Time>newest then newest:=dirinfo.Time;
    end;
    findclose(dirinfo);
    if count>1 then
    begin
    findfirst(paramstr(1),archive,dirinfo);
    repeat
    if (DOSerror=0) and (dirinfo.Time<newest) then eraseit;
    findnext(dirinfo);
    until (DOSerror<>0);
    findclose(dirinfo);
    end;
    end
    else
    begin
    writeln('Usage: DELOLD [filemask]');writeln;
    writeln('DELOLD delete the oldest occurances of the mask specified.');
    end;
    end.

    Nick

    --- Renegade vY2Ka2
    * Origin: Joey, do you like movies about gladiators? (618:500/24)
  • From Nick Andre@618:500/24 to All on Wednesday, July 26, 2023 17:46:42
    Quick and dirty Freepascal program to report drive space free.

    Used here for Darkrealms nightly reporting.

    program dfree;
    uses dos;

    var mb : longint;
    err : integer;
    t : text;

    begin
    writeln('Dfree 1.0/Win32 Copyright (c) by Nick J. Andre, Ltd.');
    writeln;
    if paramstr(1)>'' then
    begin
    val(paramstr(1),mb,err);
    if (err=0) then
    begin
    if ((DiskFree(0) div 1024) div 1024)<=mb then
    begin
    writeln('Less than '+paramstr(1));
    assign(t,'DFREE.!!!');
    (*$I-*) rewrite(t);
    if ioresult=0 then close(t);
    end
    else
    writeln('Greater than '+paramstr(1));
    end;
    end
    else
    begin
    writeln('Usage: DFREE [size in MB]');writeln;
    writeln('DFREE creates DFREE.!!! if the disk space is less than specified.');
    end;
    end.

    Nick

    --- Renegade vY2Ka2
    * Origin: Joey, do you like movies about gladiators? (618:500/24)