IPWorks ZIP 2020 Python Edition

Questions / Feedback?

extract Method

Extracts a single file, directory, or group of files, from the archive.

Syntax

def extract(filenames: str) -> None: ...

Remarks

extract extracts one or more files from the archive. The file(s) will be extracted to the directory specified by extract_to_path, and given the names found in the archive or specified by the file_decompressed_name of the file in the files collection.

Filenames may be set to one or more filenames or directory names. Files may be specified with or without a path, and with or without wildcards. If a path is specified, files in the indicated directory will be affected; subdirectories will be recursed into if recurse_subdirectories is true. If no path is specified but wildcards are, matching files in all directories will be affected. If a single filename without a path is specified, it must correspond exactly to the appropriate value of file_compressed_name.

Directories should end with a slash ("/"). If a directory is specified, all files and subdirectories in the specified directory will be affected.

A pipe character ("|") should be used to separate multiple file or directory names. Alternatively, the method may be invoked repeatedly.

The excluded_files property may be used to further limit the files to be extracted. When extract is used to extract a directory or match wildcards, each file to be extracted is first compared against excluded_files, and any files marked as excluded will not be extracted. When extract is used to extract a single file, the value of excluded_files will be ignored.

To extract all files in the archive, the extract_all method may be used.

The on_begin_file and on_end_file events will be fired before and after each file is extracted, and the on_progress event will be fired as the data is extracted. If WriteToProgressEvent is set to true, the decompressed data will be streamed out through the on_progress event.

Example


ZipControl.ArchiveFile = "c:\test.tar"
ZipControl.ExcludedFiles = "*.bak | backup/"
ZipControl.ExtractToPath = "c:\temp"
ZipControl.Extract("*")
Example
ZipControl.ArchiveFile = "c:\test.zip"
ZipControl.ExcludedFiles = ""
ZipControl.ExtractToPath = "c:\temp"
ZipControl.Extract("code/")
Example
ZipControl.ArchiveFile = "c:\test.jar"
ZipControl.ExcludedFiles = "*.txt"
ZipControl.ExtractToPath = "c:\"
ZipControl.Extract("* | docs/readme.txt")

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks ZIP 2020 Python Edition - Version 20.0 [Build 8300]