Compress Files

Declaration

<AMCOMPRESS SOURCE="text" ARCHIVEFILE="text" TYPE="text (options)" COMPRESSION="text (options)" PATHINFO="text (options)" OVERWRITE="YES/NO" ISNEWER="YES/NO" ISNEWERTHAN="text (date expression)" ISOLDERTHAN="text (date expression)" ARCHIVETURNOFF="YES/NO" PASSWORD="text (encrypted)" DOSFORMAT="YES/NO" ATTRFILTER="text" />

See Also

Description

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

Practical Usage

Generally used to compress files before backing them up or in preparation for transfer over the Internet via FTP or E-mail.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

Files to Compress

Text

Yes

(Empty)

a)SOURCE="c:\sourcefolder\file.txt"
b)SOURCE="c:\sourcefolder\*.txt"
c)SOURCE="C:\folder1\*.txt|*.doc"
d)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 (i.e. * or ?) may be used to compress all files matching a certain mask. Multiple files and/or file masks may be specified by separating the entries with a pipe symbol (|). Example: *.txt|*.bak

Destination File

Text

Yes

(Empty)

a)ARCHIVEFILE="c:\destfolder\file.zip"
b)ARCHIVEFILE="c:\destfolder\*.zip"
c)ARCHIVEFILE="file.zip"

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

Compression Type

Text Options

Yes

Zip

TYPE="tar"

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

  • Zip (Default)

  • Cab

  • LHA

  • Jar

  • GZip

  • Tar

Level of Compression

Text Options

Yes

Normal

DESTKEY="keyName"

Indicates the level of compression that should be used for the file(s) being compressed. The more compression that is used, the slower the process. No Compression is the fastest option.  

The available options are:

  • Max: The highest level of compression, resulting in the smallest files but slower operation.

  • Normal: Standard compression algorithm used, offers a good balance of speed and file size.

  • Fast: Faster operation, less compression and slightly larger target file.

  • Superfast: Even faster operation, even less compression and larger target file.

  • No Compression: Fastest, no compression applied whatsoever. Useful for combining files into a package quickly when size is not a concern.

 

Options Properties

Property

Type

Required

Default

Markup

Description

Include Subfolders

Yes/No

No

Yes

SUBFOLDERS="no"

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

Preserve Folder Structure

Text

No

Relative

PATHINFO="absolute"

Specifies how path information should be stored in the compressed file that is created. Valid only if the Include Subfolders parameter is set to YES. If set to NO, this parameter is ignored. The available options are:

  • Do not store path: Folder information is not preserved.

  • Store relative path: Folder information relative to (beneath) the current folder is stored in the compressed file. Folders above the current source directory will not be stored. For example, if compressing c:\documents\folder\*.*, the path of \folder\ will be stored in the file.

  • Store absolute path: Full folder information is stored in the compressed file, including folders above the current source folder. For example, if compressing c:\documents\folder\*.*, the full path of \documents\folder\ will be stored in the file.

Overwrite if exist

Yes/No

No

No

OVERWRITE="yes"

If set to YES, indicates that, if matching file(s) already exist in the compressed file, they will be overwritten. The default value is NO.

Only if newer

Yes/No

No

No

ISNEWER="yes"

If set to YES, specifies that only matching files that are newer than those in the compressed file will be overwritten. The default value is NO. Valid only if the Overwrite if exist parameter is set to YES.

Turn archive attribute off

Yes/No

No

No

ONLYFOLDERSTRUCT="yes"

If set to YES, denotes 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. The default value is set to NO.

Store files in DOS 8.3 format

Yes/No

No

No

DOSFORMAT="yes"

If set to YES, specifies that the filenames in the compressed file should be truncated to their 8.3 DOS style equivalents.

NOTE: 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

No

(Empty)

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

No

(Empty)

EXCLUDE="*.txt"

Causes the action to omit compressing files matching the mask(s) specified. Wildcard masks (i.e. * or ?) may be used. Multiple entries may be specified by separating them with a pipe symbol (|). Example: *.txt|*.bak

Only if newer than

Date

No

(Empty)

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 this parameter is left blank or not included, the date of the files will be ignored (excluding Only if newer parameter).

Only if older than

Date

No

(Empty)

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 this parameter is left blank or not included, the date of the files will be ignored (excluding Only if newer parameter).

 

Attributes Properties

Property

Type

Required

Default

Markup

Description

Attributes

Text Options

No

(Empty)

ATTRFILTER="+R+A-H" (compress read-only & archive files but not hidden 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, a single text item must be specified that contains the attributes of the files you wish to compress. Available Options:

  • R—Read-only: Specifying "+R" causes files with this attribute turned on to be included, "-R" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • A—Archive: Specifying "+A" causes files with this attribute turned on to be included, "-A" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • S—System: Specifying "+S" causes files with this attribute turned on to be included, "-S" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • H—Hidden: Specifying "+R" causes files with this attribute turned on to be included, "-H" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • C—Compression: Specifying "+C" causes files with this attribute turned on to be included, "-C" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

 

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties allows you to instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables and Functions

All text fields allow the use of expressions such as variables, functions or AutoMate extended functions, which can be entered by surrounding the expression in percentage signs (example: %FileDateTime(myVar)% or %myVar%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on function

More on extended functions
More on the expression builder

Example

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

 

Description: Compress file(s) from "c:\sourcefolder\*.*" into the file "c:\targetfolder\targetfilename.zip".  Use Zip compression.  Use fast compression.  Overwrite existing files.  Exclude the file mask(s) "*.txt".  

 

<AMCOMPRESS SOURCE="c:\sourcefolder\*.*" ARCHIVEFILE="c:\targetfolder\targetfilename.zip" TYPE="zip" COMPRESSION="fast" EXCLUDE="*.txt" OVERWRITE="YES" />

 

↑ Top of Page