Extract
Last updated
Was this helpful?
Extract the source file or folder to the destination folder using the specified format:
The destination argument is the directory where extracted entries are written. Older code may use target; the transpiler maps target to destination for compatibility.
- zip - gzip - bzip - bzip2 - tar - tbz - tbz2 - tgz - tar.gz
The {@code overwrite} argument is used to overwrite the destination file if it already exists, else it will throw an exception. The default is {@code false}.
The {@code recurse} argument is used to extract the files recursively. The default is {@code true}.
The {@code filter} argument is used to filter the files to extract. It can be:
- A string with a regular expression to match the file names. Example: ".*\\.txt" - A Function/Lambda that receives the file name and returns a boolean. Example: (name) => name.endsWith(".txt")
The {@code entryPaths} argument is used to extract only the files that match the given paths. It can be a string or an array of strings with the paths to extract. Example: "folder1/file1.txt" or ["folder1/file1.txt", "folder2/file2.txt"]
Extract(format=[string], source=[string], destination=[string], overwrite=[boolean], recurse=[boolean], filter=[any], entryPaths=[any])format
string
true
The format to use for extraction: zip, gzip, bzip, bzip2, tar, tbz, tbz2, tgz, or tar.gz.
source
string
true
The absolute path to the archive file or folder to extract.
destination
string
true
The absolute path to the directory where extracted files are written.
overwrite
boolean
false
Whether to overwrite the destination file if it already exists. Default is false.
false
recurse
boolean
false
Whether to extract the files recursively. Default is true.
true
filter
any
false
A regular expression or a Function/Lambda to filter the files to extract.
entryPaths
any
false
The paths to extract. It can be a string or an array of strings.
Extract a zip-file and save the data in the "output-directory".
Extract all zip-files, which are stored in the "multiple-directory" and save the data in the "output-directory".
Extract a tbz2 archive:
Last updated
Was this helpful?
Was this helpful?
extract(
source = "test.zip",
destination = "output-directory",
format = "zip"
)
extract(
source = "multiple-directory",
destination = "output-directory",
format = "zip"
)
extract(
source = "/tmp/project.tbz2",
destination = "/tmp/project-out",
format = "tbz2"
)extract(
source = "D:\\test.zip",
destination = "D:\\zipresult",
format = "zip"
)
