Compression - Compress

Declaration

<AMCOMPRESSION SOURCE="text" ARCHIVEFILE="text" TYPE="text (options)" COMPRESSION="text (options)" PASSWORD="text (encrypted)" OVERWRITE="YES/NO" ISNEWER="YES/NO" SUBFOLDERS="YES/NO" KEEPFOLDERSTRUCT="YES/NO" ARCHIVETURNOFF="YES/NO" EXCLUDE="text" RE="YES/NO" ISNEWERTHAN="text (date expression)" ISOLDERTHAN="text (date expressoin)"  ATTRFILTER="+r+a-s-h-c-e" />

Related Topics    

Description

Compresses one or more files using the specified compression algorithm into a destination file. To compress more than one file, use wildcard characters (for example, * or ?). To specify multiple files or wildcard masks, separate them with the pipe character (|) (for example, c:\temp\*.txt|c:\backup\*.bak). See File Masks & Wildcards for more details.

Practical usage

Generally used to compress files before backing them up or transferring them over the Internet by way of the FTP - Upload or Email - Send message activities. Shrinking the overall size of one file instead of dozens or hundreds of smaller files can speed up transfers and alleviate bottlenecks.

Parameters

General

Property Type Required Default Markup Description
Files to compress Text Yes (Empty)
  • SOURCE="c:\folder1\file.txt"
  • SOURCE="c:\folder1\*.txt"
  • SOURCE="file.txt"
The path and file name of the files to compress. This can be a fully qualified path and file name (preferred) or a single file (requires use of the File System - Change folder activity). You can use wildcard characters (for example, * or ?) to specify all files matching a certain mask. You can specify multiple files and file masks by separating each entry with a pipe character (|) (for example, c:\temp\*.txt|c:\backup\*.bak). See File Masks & Wildcards for more details.
NOTE: Files with invalid paths will be ignored at runtime.
Destination file Text Yes (Empty)
  • ARCHIVEFILE="c:\folder\file.zip"
  • ARCHIVEFILE="c:\folder\*.zip"
  • ARCHIVEFILE="filename.zip"
File compression combines all of the files specified into a single compressed file. This parameter specifies a fully qualified path and file name 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
  • TYPE="zip"
  • TYPE="jar"
  • TYPE="gzip"
  • TYPE="tar"
  • TYPE="bzip2"
  • TYPE="cab"
  • 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. Automate Desktop supports the following compression types:
  • ZIP (default) - Zipped file
  • JAR - Jar file
  • GZIP - Gnu zipped file
  • TAR - TAR archive
  • BZIP2 - Bzip2 compressed file
  • TAR + GZIP - Bzip2 compressed archive
  • CAB - Cab archive
  • 7ZIP - 7-Zip compressed file
Adjust Text (options) Yes 2 COMPRESSION="3" The level of compression (0 = none up to 4 = highest) to apply to the files to compress. 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 Text No (Empty) PASSWORD="text (encrypted)" If selected, the compressed file is password-protected using the password specified in the text box. Upon extraction, the user is prompted to enter the password specified in this parameter. This parameter is disabled by default.

File Options

Property Type Required Default Markup Description
Exclude Mask Text No (Empty)
  • EXCLUDE="*.txt"
  • EXCLUDE="*.txt|*.bak
  • EXCLUDE="c:\foldename"
Causes this activity to omit compressing source files matching the masks specified. Wildcard masks (for example, * or ?) may be used. Multiple entries may be specified by separating them with a pipe character (|) (for example, *.txt|*.bak). See File Masks & Wildcards for more details.
Regular expression Yes/No No No RE="YES" If selected, indicates that any value entered in the Exclude mask parameter will be treated as a regular expression. If disabled (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.        
Overwrite if exists Yes/No No No OVERWRITE="YES" If selected, indicates that, if files with matching names already exist in the compressed file, they will be overwritten. If disabled, 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 selected, 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 selected. The default value is NO.
Include subfolders Yes/No No Yes SUBFOLDERS="YES" If selected, specifies that, if present, subfolders will be searched for files matching the mask specified in the Files to compress parameter. If disabled, subfolders will be ignored. The default value is selected.
Preserve folder structure Text No Relative KEEPFOLDERSTRUCT="YES" If selected, specifies that the complete folder structure (also known as absolute path) 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. If set top NO, folder information is not preserved.  This parameter is active only if the Include subfolders parameter is selected.
Turn archive attribute off Yes/No No No ARCHIVETURNOFF="YES" If selected, denotes that the "archive" attribute of the source files 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 disabled.

File Attributes

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 files. 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. The available options are:
  • Read-only attribute is - Specifying On or +R includes files with this attribute turned on. Specifying Off or -R includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • Archive attribute is - Specifying On or +A includes files with this attribute turned on. Specifying Off or -A includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • System attribute is - Specifying On or +S includes files with this attribute turned on. Specifying Off or -S includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • Hidden attribute is- Specifying On or +H includes files with this attribute turned on. Specifying Off or -H includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • Compression attribute is - Specifying On or +C includes files with this attribute turned on. Specifying Off or -C includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • Encrypted attribute is - Specifying On or +E includes files with this attribute turned on. Specifying Off or -E includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.

Description

Error Causes

On Error

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

This sample task compresses files from a folder into a .zip file (Zip compression) using fast compression (1), overwrites any existing files, and excludes the file masks *.txt.  

Copy
<AMCOMPRESSION SOURCE="c:\sourcefolder\*.*" ARCHIVEFILE="c:\targetfolder\targetfilename.zip" COMPRESSION="1" OVERWRITE="YES" EXCLUDE="*.txt" />