zip extract files

Prev Next

Function Names

zip extract files

Library

Zip Library

Description

This function extracts one or more files from the ZIP file. No exceptions are asserted in case a specified file has not been found in the archive. If needed, check If the extracted file is existing after calling this function.

Call as: procedure

Restrictions

Under normal conditions, the 'Zip Library' is loaded automatically, so no 'include(...)' call is needed.

Parameter count

2-3

Parameters

No.TypeDescription
1.
input
string Archive file name

Choice of file or directory name. If directory name is chosen, then the whole directory with all contents will be compressed. Wildcards e.g. (pictures\*.jpg) are allowed. In this case, 2nd parameter (Archive file name) is also required to provide a concrete archive name.

2.
input
parameter set or string Content file names

Specify all files to extract:

  • Use string type to specify 1 file.
  • Use aparameter set to specify multiple files
  • Alternatively use softquoted string (with single quotation marks) with file names spearated by comam to specify multiple files.

Opt. 3.
input
string Target directory name

Specify the directory where the extracted files shall be copied to.

Default value: (current working directory)

Examples

      include( Zip Library );

      zip compress( "Examples\*.csv", "All csv.zip" );
      zip extract files( "All csv.zip", "Examples\Cities.csv", "My Dir" );

      echo("List the extracted file from 'All csv.zip':", new line);
      directory listing recursive( d, "My Dir" );
      table keep columns( d, {Path,Name,Date Created,Directory,Size} );
      table list( d );

      directory delete recursive ( "", "My Dir" );
      file delete( "All csv.zip" );

Output

List the extracted file from 'All csv.zip':

    0 : Path    | Name       | Date Created | Directory | Size
    1 : My Dir\ | Cities.csv | 2024-02-11   | No        | 1035

Try it yourself: Open LIB_Function_zip_extract_files.b4p in B4P_Examples.zip. Decompress before use.

See also

zip extract all
zip compress