Rename File Action

Description

Renames one or more files from a source path to a destination path. 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 ?). To specify multiple file names or wildcard masks, separate them with a pipe symbol. Example: c:\*.txt|c:\*.bak.

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" />

Examples

<AMFILERENAME SOURCE="c:\folder1\*.*" DEST="c:\folder2\" SUBFOLDERS="YES" OVERWRITE="YES" />

<AMFILERENAME SOURCE="c:\folder1\originalname.txt" DEST="c:\folder2\newname.txt" SUBFOLDERS="YES" OVERWRITE="YES">

<AMFILERENAME SOURCE="c:\folder1\*.*" DEST="c:\folder2\" SUBFOLDERS="YES" OVERWRITE="YES" ISNEWERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%" RESULTDATASET="RenamedFilesDS" />

<AMFILERENAME SOURCE="C:\FolderName\FileName1.doc" DEST="C:\FolderName\FileName2.doc" OVERWRITE="YES" ISNEWER="YES" OVERWRITEREADONLY="YES" ATTRFILTER="-a-s" RESULTDATASET="RenamedFilesDS" />

General Tab Parameters

Original file name: Specifies the files 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. Multiple files and file masks may be specified by separating the entries with a pipe (|) symbol.

Text, Required
MARKUP:
a) SOURCE="c:\sourcefoldername\file.txt"
b) SOURCE="c:\sourcefoldername\*.txt"
c) SOURCE="C:\sourcefoldername\*.txt|C:\sourcefoldername\*.doc"
d) SOURCE="file.txt"

New file name: Specifies 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.

Text, Required
MARKUP:
a) DEST="c:\destfoldername\newfilename.txt"
b) DEST="c:\destfoldername\*.txt"
c) DEST="c:\destfoldername\"
d) DEST="newfilename.txt"

Create and populate dataset with result information: Specifies the name of a dataset to be created and populated with the result. In addition to the standard dataset fields, the dataset will contain the following:

  • Source: the path and file name of the source file

  • Destination: the path and file name of the destination file

  • Result: the result of the action—0 for success, or an error code for failure

  • Message: textual information about the result

Text, Optional
MARKUP: RESULTDATASET="DatasetName"

Options Tab

Include Subfolders: When set to YES (selected), specifies that, if present, subfolders should be searched for files matching the mask specified in the Source [SOURCE] parameter

Yes/No, Optional, Default: NO
MARKUP: SUBFOLDERS="YES"

Preserve folder structure: Valid only if the Include subfolder [SUBFOLDERS] parameter is YES. When set to YES (selected), specifies that subfolders found in the source folder should be created in the destination folder and source files should be copied into their respective folders rather than directly into the root of the target folder specified in the Destination [DEST] parameter. If the Include subfolders [SUBFOLDERS] parameter is set to NO this parameter is ignored.

Yes/No, Optional, Default: YES
MARKUP: KEEPFOLDERSTRUCT="NO"

Overwrite if exist: When set to YES (selected), specifies that, if files already exist in the destination folder, they should be overwritten.

Yes/No, Optional, Default: NO
MARKUP: OVERWRITE="YES"

Only if newer: Valid only if the Overwrite if exist [OVERWRITE] parameter is YES. When set to YES (selected), specifies that only files that are newer than those in the destination folders will overwrite existing files

Yes/No, Optional, Default: NO
MARKUP: ISNEWER="YES"

Only if exist in destination: Valid only if the Overwrite if exist [OVERWRITE] parameter is YES. When set to YES (selected), specifies that only files that already exist in the destination will be copied from the source. All other files, regardless of whether they match the mask or other parameter settings will be bypassed.

Yes/No, Optional, Default: NO
MARKUP: ONLYIFEXIST="YES"

Overwrite read-only files: Valid only if the Overwrite if exist [OVERWRITE] parameter is YES. When set to YES (selected), specifies that 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.

Yes/No, Optional, Default: NO
MARKUP: OVERWRITEREADONLY="YES"

Overwrite hidden files: Valid only if the Overwrite if exist [OVERWRITE] parameter is YES. When set to YES (selected), 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 bypassed.

Yes/No, Optional, Default: NO
MARKUP: OVERWRITEHIDDEN="YES"

Turn archive attribute off: When set to YES (selected), 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.

Yes/No, Optional, Default: NO
MARKUP: ARCHIVETURNOFF="YES"

Exclude mask: Causes the action to not copy files matching the masks specified. Filenames or wildcard masks may be used. Multiple entries may be specified by separating them with a pipe symbol (|), for example: *.txt|*.bak

Text, Optional, Default: (blank)
MARKUP: EXCLUDE="*.txt"

Only if newer than: Causes the action to only copy files if the source is newer than the date/time specified. If parameter is left blank or not included, the date of the files will be ignored (excluding Only if newer [ISNEWER] parameter).

Date, Optional, Default: (none)
MARKUP: ISNEWERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

Only if older than: Causes the action to only copy files if the source is older than the date/time specified. If parameter is left blank or not included, the date of the files will be ignored (excluding Only if newer [ISNEWER] parameter).

Date, Optional, Default: (none)
MARKUP: ISOLDERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

Click Custom to select from other time options (Last 30 seconds, Last 30 minutes, Last 24 hours, Last 30 Days, Last 12 Months, Last 5 Years, Next 30 Seconds, Next 30 Minutes, Next 24 Hours, Next 30 Days, Next 12 Months, Next 5 Years). A expression appears in the text box (e.g., %DateAdd( "s", -30, CStr( Now() ))%) and the Expression check box is selected. You can also click the Expression Builder icon to build a custom expression.

Attributes Tab

 

Attributes: This group of settings causes the action to filter which files are copied 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 copy. The available options are:

  • 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 "+H" 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.

Text, Optional (blank)
MARKUP:
ATTRFILTER="+R+A-S-H" (move read-only and archive files, not system or hidden)
ATTRFILTER="-S" (do not move "system" files)