File System - Move

Declaration

<AMFILESYSTEM ACTIVITY="move" MERGEFOLDER="yes/no" OVERWRITE="yes/no" ISNEWER="yes/no" ONLYIFEXIST="yes/no" OVERWRITEREADONLY="yes/no" OVERWRITEHIDDEN="yes/no" EXCLUDE="text" RE="yes/no" ISNEWERTHAN="DateSerial" MODE="text (options)" SOURCE="text" DEST="text" RESULTDATASET="text" />

Description:

Moves a single or multiple files or folders from a source path to a destination path. To specify more than one file/folder, use wildcard characters (* or ?). To specify multiple wildcard masks, separate them with a pipe symbol (e.g.,c:\*.txt|c:\*.bak). If an attempt is made to move a file/folder to a destination folder that does not exist, it will be created during runtime. This activity can optionally rename and/or move a file/folder to a different location by specifying a new destination path and filename/foldername.

Practical Usage

Commonly used to move one or more files or complete folder structures to another location, drive, or share on the network. Can be used to move files generated by other activities and/or overwrite an existing copy of a destination file.

Parameters

General

Property

Type

Required

Default

Markup

Description

File/Folder

Text (options)

Yes

File

  1. MODE="file"

  2. MODE="folder"

Indicates what object(s) this activity should move. Parameters vary depending on the option selected. The available options are:

  • File (default) -  One or more files will be moved.

  • Folder - One or more folders will be moved.

Source

Text

Yes

(Empty)

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

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

  3. SOURCE="c:\folder\*.txt|c:\folder\*.bak"

  4. SOURCE="c:\foldername\subfoldername

The path of the file(s)/folder(s) to move. This can be a fully qualified path and filename/foldername (preferred) or a single file/folder (requires use of the Change folder activity). Wildcard characters (* or ?) may be used to move files/folders matching a certain mask. Multiple file masks may be specified by separating each entry with a pipe symbol (c:\*.txt|c:\*.bak).

Destination

Text

Yes

(Empty)

  1. DEST="c:\destfolder\file.txt"

  2. DEST="c:\destfolder\*.txt

  3. DEST="c:\destfolder\*.*"

  4. DEST="c:\destfolder\

The destination folder and/or filename in which to move the source file(s)/folder(s). If the destination folder does not exist, it will be created during runtime.

Create and Populate Dataset with Result Information

Text

No

(Empty)

RESULTDATASET="DatasetName"

The name of the dataset to create and populate with results of this operation. More information about the individual fields that this dataset creates can be found below under Datasets.

File Options

Property

Type

Required

Default

Markup

Description

Include subfolders

Yes/No

No

No

SUBFOLDERS="YES"

If set to YES, denotes that, if present, subfolders should be searched for files matching the mask specified in the Source parameter. If set to NO (default), subfolders are ignored. This parameter is available only if the Mode parameter is set to File.

Preserve folder structure

Yes/No

No

Yes

KEEPFOLDERSTRUCT="NO"

If set to YES (default), subfolders found in the source folder will be created in the destination folder and source files will be moved into their respective folders rather than directly into the root of the target folder specified in the Destination parameter. If set to NO, source files will be moved into the root of the target folder instead. This parameter is active only if the Include Subfolders parameter is set to YES.

Merge if folder exists

Yes/No

No

No

MERGEFOLDER="yes"

If set to YES, specifies that, if a matching folder already exists in the destination, the source folder and all its contents will be merged onto that folder. If set to NO (default) the merge will not take place, however, a runtime error will occur as a result.  This parameter is available only if the Mode parameter is set to Folder.

Overwrite if exists

Yes/No

No

No

OVERWRITE="YES"

If set to YES, matching destination files/folders will be overwritten. If set to NO, no files/folders will be overwritten, however, an error will occur as a result.

Only if newer

Yes/No

No

No

ISNEWER="YES"

If set to YES, only source files/folders that are newer than those that match in the destination folder will overwrite existing files. Set to NO by default. This parameter is active only if the Overwrite if exists parameter is set to YES.

Only if exists in destination

Yes/No

No

No

ONLYIFEXIST="YES"

If set to YES, only matching files/folders that already exist in the destination will be overwritten. All other files, regardless of whether they match the mask or other parameter settings will be bypassed. This parameter is set to NO by default and is active only if the Overwrite if exists parameter is set to YES.

Overwrite read-only files

Yes/No

No

No

OVERWRITEREADONLY="YES"

If set to YES, matching files/folders marked with the read-only attribute that already exist in the destination will be overwritten. By default, read-only files are not overwritten. This parameter is active only if the Overwrite if exists parameter is set to YES.

Overwrite hidden files

Yes/No

No

No

OVERWRITEHIDDEN="YES"

If set to YES, matching files/folders marked with the hidden attribute that already exist in the destination will be overwritten. By default, hidden files are not overwritten. This parameter is active only if the Overwrite if Exist parameter is set to YES.

Turn archive attribute off

Yes/No

No

No

ARCHIVETURNOFF="YES"

If set to YES, specifies 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. Turning the source file's archive attribute off indicates to many backup programs that the file has already been backed-up. This parameter is set to NO by default and only available if the Mode parameter is set to File.

Exclude mask

Text

No

(Empty)

  1. EXCLUDE="*.txt"

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

  3. EXCLUDE="c:\foldename"

Causes this activity 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 value entered in the Exclude mask parameter will be interpreted as a regular expression. If set to NO (default), the value will be interpreted 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 move 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). Click the Custom button to select from a list of pre-defined date parameters. Enable the Expression checkbox 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 the action to only move 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). Click the Custom button to select from a list of pre-defined date parameters. Enable the Expression checkbox to allow entry of a date/time expression.

File Filter

Property

Type

Required

Default

Markup

Description

Attributes

Text (options)

No

(Empty)

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

This group of settings causes the action to filter which files are moved 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 copy. 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

Error Causes

On Error

Datasets

A dataset is a multiple column, multiple row container object. This activity creates and populates a dataset containing a specific set of fields. The table below describes these fields (assuming the dataset name assigned was theDataset).

Name

Type

Return Value

theDataset.Source

Text

The path and file name of the source folder/ file.

theDataset.Size

Number

The size of the folder/file (in KB).

theDataset.Destination

Text

The path and file name of the destination file.

theDataset.Result

True/False

Returns TRUE if result of activity is a success, otherwise, returns a FALSE.

theDataset.Message

Text

The textual information associated to the result.

Examples

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

Sample 1: Move file(s) from "c:\temp\*.pdf" to "c:\archive\*.*".Create and populate dataset "theDataset" with details of the File(s). Include subfolders. Preserve folder structure. Overwrite existing file(s). Only if exists in destination. Only if newer. Overwrite read-only files. Overwrite hidden file(s). Turn off the archive attribute. Exclude the file mask(s) "text". Only if newer than "3/15/2013 1:30:27 PM".

 

<AMFILESYSTEM ACTIVITY="move" SUBFOLDERS="yes" KEEPFOLDERSTRUCT="yes" OVERWRITE="yes" ISNEWER="yes" ONLYIFEXIST="yes" OVERWRITEREADONLY="yes" OVERWRITEHIDDEN="yes" ARCHIVETURNOFF="yes" EXCLUDE="text" RE="yes" ISNEWERTHAN="%DateSerial(2013,03,15)+TimeSerial(13,30,27)%" SOURCE="c:\temp\*.pdf" DEST="c:\archive\*.*" RESULTDATASET="theDataset" />

 

Sample 2: - Move folder(s) from "c:\temp\*" to "c:\archive\*".Create and populate dataset "theDataset" with details of the Folder(s). Overwrite existing file(s). Only if exists in destination. Only if newer. Overwrite read-only files. Overwrite hidden file(s). Exclude the file mask(s) "text". Only if newer than "3/15/2013 1:30:27 PM".

 

<AMFILESYSTEM ACTIVITY="move" OVERWRITE="yes" ISNEWER="yes" ONLYIFEXIST="yes" OVERWRITEREADONLY="yes" OVERWRITEHIDDEN="yes" EXCLUDE="text" RE="yes" ISNEWERTHAN="%DateSerial(2013,03,15)+TimeSerial(13,30,27)%" MODE="folder" SOURCE="c:\temp\*" DEST="c:\archive\*" RESULTDATASET="theDataset" />