[fpc-pascal] An example to compress all files in a directory?

Michael Van Canneyt michael at freepascal.org
Mon Aug 31 16:51:59 CEST 2009



On Mon, 31 Aug 2009, luca_manganelli at comune.trento.it wrote:

>
> Hi all,
>
> I cannot find the documentation of Zipper so I ask you an example to
> compress all files in a directory using this unit.

{$mode objfpc}
{$h+}
Program testzip;

uses Classes,Zipper;

Var
   S : TStringList;
   I : Integer;

begin
   S:=TStringList.Create;
   For I:=2 to ParamCount do
     S.Add(ParamStr(I));
   With TZipper.Create do
     try
       ZipFiles(ParamStr(1),S);
     Finally
       Free;
     end;
end.

run in directory on linux as

testzip myzipfile *.*

If you are on windows, you need to expand the *.* yourself.

Michael.



More information about the fpc-pascal mailing list