Compress Files Action

Declaration

<AMCOMPRESS TYPE="options" SOURCE="text" COMPRESSION="options" PATHINFO="options" EXCLUDE="text" OVERWRITE="yes/no" ISNEWER="yes/no" ISNEWERTHAN="datetime" ISOLDERTHAN="datetime" ARCHIVETURNOFF="yes/no" PASSWORD="text" DOSFORMAT="yes/no" ATTRFILTER="text">

See Also

Decompress Files Action, Encrypt Action, Decrypt Action, Calculate File Checksum Action, Split File Action

Description

Compresses files into the file specified. To specify more than one file to compress use wildcards ( e.g. * or ? ). To specify multiple files or wildcard masks, separate them with a vertical bar. Example: c:\*.txt|c:\*.bak

Practical Usage

Usually used to compress files before backing up or in preparation for transfer over the Internet via email or FTP.

Parameters

General Tab

Files to Compress

Text, Required
MARKUP:
a) SOURCE="c:\sourcefoldername\file.txt"
b) SOURCE="c:\sourcefoldername\*.txt"
c) SOURCE="C:\sourcefoldername\*.txt|C:\sourcefoldername\*.doc"
c) SOURCE="file.txt"

Specifies the file(s) to compress. This can be a fully qualified path and filename (preferred) or a single file (requires use of the Change Folder action). Wildcards ( e.g. *.* or ? ) may be used to copy all files matching a certain mask. Multiple file and/or file masks may be specified by separating the entries with the | symbol.

Destination File

Text, Required
MARKUP:
a) DEST="c:\sourcefoldername\file.txt"
b) DEST="c:\sourcefoldername\*.txt"
c) DEST="file.txt"

Specifies the destination folder and filename for the file(s) being compressed. This should be a fully qualified path with a filename. Folders that do not exist will be automatically created at runtime.

Compression Type

Text, Optional default - "zip"
MARKUP:
a) TYPE="zip"
b) TYPE="cab"
c) TYPE="lha"
d) TYPE="tar"

Specifies the type of compression that should be used for the file(s) being compressed. AutoMate supports the following compression types:

Level of Compression

Text, Optional default - normal
MARKUP:
a) COMPRESSION="max"
b) COMPRESSION="fast"
c) COMPRESSION="super_fast"
d) COMPRESSION="none"

Specifies the level of compression that should be used for the file(s) being compressed. The more compression that is used the slower the process. "none" is the fastest option.

The available options are:

 

Options Tab

Include subfolders

Yes/No, Optional default - YES
MARKUP: SUBFOLDERS="YES"

When set to YES, specifies that, if present, subfolders should be searched for files matching the mask specified in the Files to compress parameter.

Preserve Folder Structure

Yes/No, Optional default - relative
MARKUP: PATHINFO="absolute"

Valid only if the Include subfolder parameter is set to YES. When set to YES, specifies how path information should be stored in the compressed file that is created. If the Include subfolders parameter is set to NO this parameter is ignored.

The available options are:

Include empty subfolders

Yes/No, Optional default - NO
MARKUP: EMPTYFOLDERS="YES"

Valid only if the "Include subfolder" [SUBFOLDERS] parameter is YES. When set to YES, specifies that subfolders found in the source folder should be created in the destination folder even if they are empty (i.e. they do not contain any files).

Overwrite if exist

Yes/No, Optional default - NO
MARKUP: OVERWRITE="YES"

When set to YES, specifies that, if matching file(s) already exist in the compressed file they should be overwritten.

Only if newer

Yes/No, Optional default - NO
MARKUP: ISNEWER="YES"

Valid only if the "Overwrite if exist" [OVERWRITE] parameter is YES. When set to YES, specifies that only matching files that are newer than those in the destination compressed file will be overwritten.

Turn archive attribute off

Yes/No, Optional default - NO
MARKUP: ONLYFOLDERSTRUCT="YES"

When set to YES, specifies that the "archive" attribute of the source file(s) should be switched OFF. The Windows "archive" attribute is generally used to track whether a file has been backed-up, by turning the source file's archive attribute off - this indicates to many backup programs that the file has already been backed-up.

Store files in DOS 8.3 format

Yes/No, Optional default - NO
MARKUP: DOSFORMAT="YES"

When set to YES, specifies that the filenames in the compressed file should be truncated to their 8.3 DOS style equivalents. Should only be enabled if the compressed file will be used on an older operating system that does not support long filenames.

Password protect files

Text, Optional default - (none) no password
MARKUP: PASSWORD="mypassword"

If specified, causes the compressed file to be password protected - thus the user will be prompted for a password upon extraction.

Exclude Mask

Text, Optional default - (blank)
MARKUP: EXCLUDE="*.txt"

Causes the action to not compress files matching the mask(s) specified. Filenames or wildcard (i.e. * or ?) masks may be used, multiple entries may be specified by separating them with the | symbol (e.g. *.txt|*.bak)

Only if newer than

date, Optional default - (none)
MARKUP: ISNEWERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

Causes the action to only compress files if the source is newer than the date/time specified. If parameter is left blank or not included, the date of the files will be ignored (excluding "Only if newer" [ISNEWER] parameter).

Only if older than

date, Optional default - (none)
MARKUP: ISOLDERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

Causes the action to only compress files if the source is older than the date/time specified. If parameter is left blank or not included, the date of the files will be ignored (excluding Only if newer parameter).

Attributes Tab

Attributes

Text, Optional (blank)
MARKUP:
ATTRFILTER="+R+A-S-H" (move read-only and archive files, not system or hidden)
ATTRFILTER="-S" (do not move "system" files)

This group of settings causes the action to filter which files are compressed based on the attribute settings of the source file(s). In visual mode, a group of controls are provided to assist in the selection of this parameter.

In markup mode, build a single text item must be specified that contains the attributes of the files you wish to compress.

Available Options:

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<AMCOMPRESS SOURCE="c:\sourcefolder\*.*" FILE="c:\targetfolder\targetfilename.zip" COMPRESSION="fast" PATHINFO="none" EXCLUDE="*.txt" OVERWRITE="YES" ISNEWER="YES" ISNEWERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%" ISOLDERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%" ARCHIVETURNOFF="YES" PASSWORD="test" DOSFORMAT="YES" ATTRFILTER="+a">