Renames one or more files from a source path to a destination path. This action supports multiple file renaming, such as adding a date or changing the extension on a group of files. To specify more than one file, use wildcard characters (* or ?). Commonly used as an organization tool to automate the renaming of multiple files. For instance, files can be renamed to include the current date/time, the parent folder name, department name, etc. Files can also be renamed to a new location.
Declaration
<AMFILERENAME SOURCE="text" DEST="text" SUBFOLDERS="yes/no" KEEPFOLDERSTRUCT="yes/no" OVERWRITE="yes/no" ISNEWER="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 1 - Move File action used to rename an entire directory (including all sub-directories) to another location.
<AMFILERENAME SOURCE="c:\sourcefolder\*.*" DEST="c:\destfolder\*.*" SUBFOLDERS="YES" OVERWRITE="YES" ISNEWERTHAN="%DateAdd( "d", 30, CStr( Now() )%" />
Example 2 - Move File action used to rename only files that are newer than 30 days excluding text files and overwrite existing files. The action will also create and populate a dataset with details of the files being moved.
<AMFILEMOVE SOURCE="c:\folder1\*.*" DEST="c:\folder2\" OVERWRITE="YES" ISNEWERTHAN="%DateAdd( "h", -24, CStr( Now() ))%" EXCLUDE="*.txt" RESULTDATASET="MoveFileDataset" />
Example 3 - Move File action used to rename the file being moved.
<AMFILEMOVE SOURCE="c:\folder1\originalfilename.txt" DEST="c:\folder2\newfilename.txt" OVERWRITE="YES" />
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, About Datasets
Property |
Type |
Required |
Default |
Markup |
Description |
Original File Name |
Text |
Yes |
(Empty) |
a)SOURCE="c:\sourcefolder\file.txt" b)SOURCE="c:\sourcefolder\*.txt" c)SOURCE="sourcefile.txt" |
Specifies the file(s) to rename. This can be a fully qualified path and filename (preferred) or a file name only (requires use of the Change Folder action). Wildcard characters (* or ?) may be used to rename files matching a certain mask. |
New File Name |
Text |
Yes |
(Empty) |
a)DEST="c:\destfolder\newfilename.txt" b)DEST="c:\destfolder\*.txt" c)DEST="c:\destfolder\" d)DEST="newfilename.txt" |
Indicates the destination folder and (optionally) the filename for the files being renamed. This can be a fully qualified path or a filename. Folders specified that do not exist will be automatically created at runtime. Wildcard characters (* or ?) may be used. |
Create and Populate Dataset with Result Information |
Text |
No |
(Empty) |
RESULTDATASET="DatasetName" |
The name of a dataset to be created and populated with status regarding this operation. |
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 value), subfolders are altogether ignored. |
Preserve Folder Structure |
Yes/No |
No |
Yes |
KEEPFOLDERSTRUCT="NO" |
If set to YES (default value), 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 Subfolder 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 value), empty subfolders are ignored. This parameter is active only if the Include Subfolder 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 no files will be moved. Enabling this option causes all other file-specific parameters to be ignored. This parameter is set to NO by default and active only if the Include Subfolder parameter is set to YES. |
Overwrite if Exist |
Yes/No |
No |
No |
OVERWRITE="YES" |
If set to YES, matching destination files will be overwritten. This parameter is set to NO by default. |
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 folder will overwrite existing files. Set to NO by default. This parameter is active only if the Overwrite if Exist 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 will be moved from the source. 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 Exist parameter is set to YES. |
Overwrite Read-Only Files |
Yes/No |
No |
No |
OVERWRITEREADONLY="YES" |
If set to YES, already existing files should be overwritten even if the file in the destination is marked with the read-only attribute. By 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, specifies that already existing files should be overwritten even if the file in the destination is marked with the hidden attribute. 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. |
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) |
a)ATTRFILTER="+R+A-H" b)ATTRFILTER="-S" |
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 want to move. 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.