Skip to content

ZIP Compress

Type: zip-compress  ·  Package: ZIP Activities v1.0.5  ·  Output: string

Compresses a whole folder or a list of files into a ZIP file. Returns the path of the created ZIP.

Give the destination (destination) and one of the two sources. If you give both, sourceFolder is used and files is ignored.

  • sourceFolder: compresses all its content (files and sub-folders, empty ones included), keeping the structure. The folder itself does not appear inside the ZIP: its content sits at the root.
  • files: adds each file at the root of the ZIP under its name (the source folder is not kept). Files that do not exist are skipped with a warning in the log (A file in the list was not found and was skipped.), without failing; if none exists, the ZIP ends up empty. Avoid two files with the same name from different folders: they would be duplicated inside the ZIP.
  • Overwriting: with overwrite = true (default) an existing ZIP is deleted before compressing; with false, the activity fails if the destination exists.
  • Destination folder: created if missing. Don’t save the ZIP inside the folder you are compressing.
ParameterTypeDefaultDescription
destinationstring—Path of the output ZIP file, including its folder.
ParameterTypeDefaultDescription
sourceFolderstring—Folder to compress (all its content). Give this or files.
filesList—List of file paths to compress (alternative to sourceFolder). A single path as text is also accepted.
overwritebooltrueReplace the destination ZIP if it already exists.

Returns a string with the path of the created ZIP (as you gave it in destination).

MessageCause and fix
'sourceFolder' or 'files' is required.You gave no source (or both expressions evaluated to null).
Could not find a part of the path '…'.sourceFolder does not exist. Check it first with dirExists(folder).
The file '…' already exists.The destination exists and overwrite is false.
The process cannot access the file '…' because it is being used by another process.The destination ZIP or a source file is open in another program.
'destination' is required.The destination expression evaluated to null.

Compress a folder:

ZIP Compress destination = "C:/outbox/documents.zip" sourceFolder = "C:/output/documents" → output: zipPath
Log message = "ZIP ready at " + zipPath

Compress specific files and send them:

List Files path = "C:/invoices" pattern = "*.pdf" → output: pdfs
ZIP Compress destination = "C:/outbox/invoices.zip" files = pdfs → output: zipPath
SMTP Send ... subject = "Monthly invoices" attachments = arr(zipPath)