Compression - Compress

Declaration

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

Description: Compresses one or more files using the specified compression algorithm into a destination file. To compress more than one file, use wildcard characters (* or ?). To specify multiple files or wildcard masks, separate them with the pipe "|" symbol (e.g., c:\temp\*.txt|c:\backup\*.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 activity. Compressed files enable downloading and sharing files to be easier by shrinking the overall size and allowing a user to download one file instead of dozens or hundreds of smaller files.

General Parameters

Property

Type

Required

Default

Markup

Description

Files to compress

Text

Yes

(Empty)

  1. SOURCE="c:\folder1\file.txt"

  2. SOURCE="c:\folder1\*.txt"

  3. SOURCE="file.txt"

The path and filename of 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 activity). Wildcard characters (e.g., * or ?) may be used to compress all files matching a certain mask. Multiple files and/or file masks can be specified by separating each entry with a pipe "|" symbol (e.g., c:\temp\*.txt|c:\backup\*.bak).

Destination file

Text

Yes

(Empty)

  1. ARCHIVEFILE="c:\folder\file.zip"

  2. ARCHIVEFILE="c:\folder\*.zip"

  3. ARCHIVEFILE="filename.zip"

File compression combines all of the files specified into a single compressed file. This parameter specifies a fully qualified path and filename of the archive file to be created.

NOTE:  Folders that do not exist will be automatically created at runtime.

Compression type

Text (options)

Yes

ZIP

  1. TYPE="zip"

  2. TYPE="jar"

  3. TYPE="gzip"

  4. TYPE="lha"

  5. TYPE="tar"

  6. TYPE="bzip2"

  7. TYPE="cab"

  8. TYPE="7zip"

The compression algorithm that this activity will use to compress files. Several open and proprietary compression algorithms can be used to compress files, which is why many different compressed file types exist. Supports the following compression types:

  • ZIP (Default) - Zipped file

  • JAR - Jar file

  • GZIP - Gnu zipped file

  • LHA - LHARC compressed archive

  • TAR - TAR archive

  • BZIP2 - Bzip2 compressed file

  • TAR + GZIP - Bzip2 compressed archive

  • CAB - Cab archive

  • 7ZIP - 7-Zip compressed file

Compression level

Text (options)

Yes

1

DESTKEY="keyName"

The level of compression (0 = none up to 4 = highest) that should be applied for the file(s) being compressed. Move the slider to the desired value or simply enter the value in the provided text box. Note that the higher the compression level, the smaller the destination file and the slower the operation. The available options are:

  • 0 - No compression - Fastest operation, however, no compression is applied whatsoever. Useful for combining files into a package quickly when size is not a concern.

  • 1 - Fast compression - Less compression and slightly larger target file.

  • 2 - Normal compression - Uses a standard compression algorithm that offers a good balance of speed and file size.

  • 3 - High compression - High compression level resulting in a smaller file size but slower operation.

  • 4 - Max compression - The highest level of compression, resulting in the smallest file size but slowest operation.

Password protect files

Yes/No

No

No

BPASSWORD="YES"

If set to YES, causes the compressed file to be password protected - thus the user will be prompted for a password upon extraction. Set to NO by default.

Password

Text

No

No

PASSWORD="encrypted)"

The password that must be entered by the user to extract the compressed file. This parameter is available only if the Password protect files parameter is set to YES.

File Options Parameters

Property

Type

Required

Default

Markup

Description

Include subfolders

Yes/No

No

Yes

SUBFOLDERS="no"

If set to YES, specifies that, if present, subfolders will be searched for files matching the mask specified in the Files to compress parameter. If set to NO, subfolders will be ignored. 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 to be created. Valid only if the Include subfolders parameter is set to YES. The available options are:

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

  • Store relative path (default) - 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 exists

Yes/No

No

No

OVERWRITE="yes"

If set to YES, indicates that, if files with matching names already exist in the compressed file, they will be overwritten. If set to NO, files with matching names will not be overwritten, however, an error will occur as a result. The default value is NO.

Only if newer

Yes/No

No

No

ISNEWER="yes"

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

Append

Yes/No

No

No

APPEND="yes"

If set to YES, indicates that, if files with matching names already exist in the compressed file, a number will be added to the end of the source filenames before compression takes place. This enables both files to exist in the compressed file. If this parameter is set to YES, the Overwrite if exists parameter becomes inactive. Set to NO by default.

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.

Exclude Mask

Text

No

(Empty)

  1. EXCLUDE="*.txt"

  2. EXCLUDE="*.txt|*.bak

  3. EXCLUDE="c:\foldename"

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

Regular expression

Yes/No

No

No

RE="yes"

If set to YES, indicates that any value entered in the Exclude mask parameter will be treated as a regular expression. If set to NO (default) the value will be treated as normal readable text.

Only if newer than

Date

No

(Empty)

ISNEWERTHAN=

"%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

Causes this activity to only compress source files with modified dates/times newer than the date/time specified. If this parameter is left blank or not included, modified dates of source files will be ignored. Press Custom to select from a list of pre-defined date/time values. Enable Expression to allow entry of a date/time expression.    

Only if older than

Date

No

(Empty)

ISOLDERTHAN=

"%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

Causes this activity to only compress source files with modified dates/times older than the date/time specified. If this parameter is left blank or not included, modified dates of source files will be ignored. Press Custom to select from a list of pre-defined date/time values. Enable Expression to allow entry of a date/time expression.        

File Filter Parameters

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 tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

Example

The sample AML code below can be copied and pasted directly into the Steps panel 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" />