Copies one or more files from the source path to the destination path. To specify more than one file, use wildcard characters (i.e. * or ?). Commonly used to back-up files or complete directory structures. Could also be used to send files to other computers across a network.
Declaration
<AMFILECOPY SOURCE="text" DEST="text" SUBFOLDERS="yes/no" EMPTYFOLDERS="yes/no" OVERWRITE="yes/no" ISNEWER="yes/no" ONLYFOLDERSTRUCT="yes/no" OVERWRITEREADONLY="yes/no" OVERWRITEHIDDEN="yes/no" ONLYIFEXIST="yes/no" ISNEWERTHAN="date" ISOLDERTHAN="date" ARCHIVETURNOFF="yes/no" EXCLUDE="text" ATTRFILTER="text"RESULTDATASET="text">
Example
This example performs a copy operation and saves results to a dataset. A Loop Dataset action then loops through the dataset and displays information about the copied files in a message box.
<AMFILECOPY SOURCE="C:\Folder1\*.*" DEST="C:\Folder2" SUBFOLDERS="YES" OVERWRITE="YES" ISNEWER="YES" OVERWRITEREADONLY="YES" ONLYIFEXIST="YES" ISNEWERTHAN="%DateSerial(2007,02,24) + TimeSerial(15,40,34)%" ARCHIVETURNOFF="YES" EXCLUDE="*.pri" ATTRFILTER="+a-s" RESULTDATASET="FileCopyDataset" />
<AMLOOP TYPE="DATASET" DATASET="FileCopyDataset">
<AMSHOWDIALOG WINDOWTITLE="Results of copy file operation.">Source - %FileCopyDataset.Source%
Destination - %FileCopyDataset.Destination%
Result - %FileCopyDataset.Result%
Message - %FileCopyDataset.Message%</AMSHOWDIALOG>
</AMLOOP>
See Also: Split File, Join 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, Calculate File Checksum
Property |
Type |
Required |
Default |
Markup |
Description |
Source |
Text |
Yes |
(Empty) |
a)SOURCE="c:\sourcefolder\file.txt" b)SOURCE="c:\sourcefolder\*.txt" c)SOURCE="file.txt" |
Specifies the file(s) to copy. This can be a fully qualified path and file name (preferred) or a file name only (requires use of the Change Folder action). Wildcard characters (* or ?) may be used to copy files matching a certain mask. |
Destination |
Text |
Yes |
(Empty) |
a)DEST="c:\destfolder\file.txt" b)DEST="c:\destfolder\*.*" |
Indicates the destination folder and (optionally) file name that the file(s) should be copied to. This can be a fully qualified path or a file name. Folders that do not exist will be automatically created at runtime. |
Create and populate dataset with result information |
Text |
No |
(Empty) |
RESULTDATASET="DatasetName" |
Specifies the name of a dataset to be created and populated with the results of this operation. |
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 file. |
theDataset.Destination |
Text |
The path and file name of the destination file. |
theDataset.Result |
Number |
The result of this operation - 0 for success, or the corresponding error code (number) for failure. |
theDataset.Message |
Text |
The textual information associated to the result. |
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. Only files that exist in the root of the source folder will be searched. |
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 copied into their respective folders. If set to NO, subfolders will not be created. Files that exist in these subfolders will be copied into the root of the source folder instead. This parameter is active only if the Include Subfolders parameter is set to YES. |
Include Empty Subfolders |
Yes/No |
No |
No |
EMPTYFOLDERS="YES" |
If set to YES, subfolders found in the source folder will be created in the destination folder even if they do not contain any files. If set to NO (default), empty subfolders are ignored. This parameter is active only if the Include Subfolders parameter is set to YES. |
Only Folder Structure |
Yes/No |
No |
No |
ONLYFOLDERSTRUCT="YES" |
If set to YES, subfolders found in the source folder will be created in the destination folder but files that reside in these subfolders will not be copied. This parameter is set to NO by default and is active only if the Include Subfolders parameter is set to YES. NOTE: Setting this option to YES causes all other folder-specific parameters to be ignored. |
Overwrite if Exist |
Yes/No |
No |
No |
OVERWRITE="YES" |
If set to YES, matching files found in the destination folder are to be overwritten. If set to NO (default), an error will occur as a result of a matching file found. |
Only if Newer |
Yes/No |
No |
No |
ISNEWER="YES" |
If set to YES, only source files that are newer than those that match in the destination are to be overwritten folder will overwrite existing files. If set to NO (default), all matching files found in the destination folder will be overwritten regardless of their date properties. This parameter is active only if the Overwrite if Exists parameter is set to YES. |
Only if Exist in Destination |
Yes/No |
No |
No |
ONLYIFEXIST="YES" |
If set to YES, only files that already exist in the destination folder will be copied from the source folder. 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 becomes active only if the Overwrite if Exist parameter is set to YES. |
Overwrite Read-Only Files |
Yes/No |
No |
No |
OVERWRITEREADONLY="YES" |
If set to YES, matching files found in the destination folder will be overwritten even if they are marked with the read-only attribute. If set to NO (default), read-only files are not overwritten. This parameter is active only if the Overwrite if Exist parameter is set to YES. |
Overwrite Hidden Files |
Yes/No |
No |
No |
OVERWRITEHIDDEN="YES" |
If set to YES, matching files found in the destination folder will be overwritten even if they are marked with the hidden attribute. If set to NO (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, archive attribute of the source files will 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. |
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. |
Only if Newer Than |
Date |
No |
(Empty) |
ISNEWERTHAN= "%DateSerial(2001,10,12) + TimeSerial(00,00,00)%" |
If enabled, causes this action 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 Custom 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 Custom to select from a list of pre-defined date parameters. Enable the Expression option to allow entry of a date/time expression. |
Property |
Type |
Required |
Default |
Markup |
Description |
Attributes |
Text (Options) |
No |
(Empty) |
ATTRFILTER="+R+A-H" (copy read-only & archive files but not hidden files) |
This group of settings causes the action to filter which files are affected by the attribute change based on the original attribute settings of the source files. In visual mode, a group of controls are provided to assist in the selection of this parameter. In AML mode, a single text item must be specified that contains the original attribute mask of the files you want to affect. Available Options:
|
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
The Error Causes tab allows you to select/omit specific errors that should cause a particular step to fail.
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
All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, % Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.