Concatenate Files

Declaration

<AMCONCATENATEFILE FILEA="Text" FILEB="Text" CONCATENATEDFILE="Text" OVERWRITEFILE="Text" />

See Also

Split File | Move File | Create Folder | Delete File | Delete Folder | Rename Folder | Remove Folder | Touch File | Set Attributes | Read from File | Write to File | Synchronize Folders | Concatenate Files

File System - Concatenate Files

Declaration

<AMCONCATENATEFILE FILEA="Text" FILEB="Text" CONCATENATEDFILE="Text" OVERWRITEFILE="Text" />

See Also

Change Folder | Concatenate Files | Copy | Create Folder | Delete | Get Checksum | Join Files | Move | Read From File | Rename | Split File | Synchronize Folders | Touch | Write To File

Description

Concatenates the contents of two or more files and outputs the result to a single destination file. If the destination file does not exist, it will be created. You can specify more than one file name with the use of wildcard characters (i.e. * or ?). To specify multiple files or wildcard masks, separate them with a pipe symbol (i.e. c:\*.txt|c:\*.bak). If entering a list of file names, the files will be concatenated in the order they are entered.

Practical Usage

Generally used to quickly join a group of files (typically text based files such as log files) together into a single file.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

File A

Text

Yes

(Empty)

  1. FILEA="c:\FolderA\FileA.txt"

  2. FILEA="c:\FolderA\*.txt"

  3. FILEA="c:\File.txt|c:\File.bak"

The path and file name of the first file to concatenate. To specify more than one file, use wildcard characters (i.e. * or ?). To specify multiple files or wildcard masks, separate them with a pipe symbol (i.e. c:\*.txt|c:\*.bak). Pipes do not support files with the same extension. If specifying multiple files of the same extension (i.e. *.txt) files will be concatenated in alphabetical order. If entering a list of file names separated by a pipe symbol, they will be concatenated in the order they are entered.

NOTE: Since multiple files are supported, you can specify all files you wish to concatenate within this parameter using the appropriate wildcards. The File B parameter can then be left blank.

File B (Optional)

Text

No

(Empty)

  1. FILEB="c:\FolderB\FileB.txt"

  2. FILEB="c:\FolderB\*.txt"

  3. FILEB="c:\File.txt|c:\File.bak

The path and file name of the second file to concatenate. To specify more than one file, use wildcard characters (i.e. * or ?). To specify multiple files or wildcard masks, separate them with a pipe symbol (i.e. c:\*.txt|c:\*.bak). If specifying multiple files of the same extension (i.e. *.txt) files will be concatenated in alphabetical order. If entering a list of file names separated by a pipe symbol, they will be concatenated in the order they are entered.

NOTE: Since multiple files are supported, you can specify all files you wish to concatenate in the File A parameter using the appropriate wildcards and skip this parameter altogether.

Concatenated File

Text

Yes

(Empty)

CONCATENATEDFILE="C:\Temp\FileB.txt"

The path and file name of the output (concatenated) file. If this file does not exist, it will be created at runtime.

Overwrite if file exists

Yes/No

No

No

OVERWRITEFILE="YES"

If set to YES, output (concatenated) files that already exist will be overwritten. This parameter is set to NO by default.

Encoding for concatenated file

Text

(Options)

No

Default

ENCODING="UTF8"

The encoding method set for the output (concatenated) file. The available options are:

  • Default - The default text file encoding of the host operating system.

  • Unicode - Encoding set to Unicode.

  • UTF8 - Encoding set to UTF8.

  • ASCII - Encoding set to ASCII.

NOTE: Most of the time, using the default encoding scheme for the locale of the host operating system is good enough. However, this parameter is useful if you are working with files that originate from another source.

File Options Properties

Property

Type

Required

Default

Markup

Description

Include Subfolders

Yes/No

No

No

SUBFOLDERS="YES"

If set to YES, specifies that, if present, subfolders should be searched for files matching the mask specified in the File A and/or File B parameters. This parameter is set to NO by default.

Exclude Mask

Text

No

(Empty)

EXCLUDE="*.txt"

Causes this action to omit files matching the mask(s) specified. File names or wildcard masks may be used. Multiple entries may be specified by separating them with a pipe symbol (|), for example: *.txt|*.bak

Regular Expression

Yes/No

No

No

RE="YES"

If set to YES, specifies that the data entered under the Exclude Mask field is a regular expression. Set to NO by default.

Only if Newer Than

Date

No

(Empty)

ISNEWERTHAN=

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

If enabled, causes this activity to only act on files that are newer than the date/time specified. If this parameter is left blank or disabled (default), file dates are ignored.

Click the Custom button to select from a list of pre-defined date parameters. Enable the Expression option to allow entry of a date/time expression.

Only if Older Than

Date

No

(Empty)

ISOLDERTHAN=

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

If enabled, causes this action to only act on files that are older than the date/time specified. If this parameter is left blank or disabled (default), file dates are ignored.

Click the Custom button to select from a list of pre-defined date parameters. Enable the Expression option to allow entry of a date/time expression.

File Filter Properties

Attributes Properties

Property

Type

Required

Default

Markup

Description

Attributes

Text Options

No

(Empty)

ATTRFILTER="+R+A-H" (concatenate read-only & archive files but not hidden files)

This group of settings causes the action to filter which files are concatenated 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 allows you to select/omit specific errors that should cause a particular step to fail.

More on Error Causes properties

On Error Properties

The On Error tab allows you to determine what the task should do if a particular step encounters an error.

More about On Error properties

Additional Notes

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (Example: %myVariable% or %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by clicking the Insert expression/variable button or 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.

 

 

<AMCONCATENATEFILE FILEA="C:\FolderA\FileName1.DOC" FILEB="C:\FolderB\FileName2.doc" CONCATENATEDFILE="C:\FolderC\NewConcatenatedFile" OVERWRITEFILE="YES" />

 

↑ Top of Page