File System - Set Attributes

Declaration

<AMFILESYSTEM ACTIVITY="set_attributes" SUBFOLDERS="yes/no" 
EXCLUDE="text" RE="yes/no" ISNEWERTHAN="DateSerial" 
SOURCE="text" ATTRIBUTES="+r+s+a+h" RESULTDATASET="text" />

Description: Sets the attributes of one or more files specified. To specify more than one file, use wildcards (Example: * or ?). To specify multiple files or wildcard masks, separate them with a vertical bar. (Example: c:\*.txt|c:\*.bak).

Practical Usage

Used to set the attributes of one or more files. More on RASH File Attributes can be found below.

General Parameters

Property

Type

Required

Default

Markup

Description

Source

Text

Yes

(Empty)

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

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

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

The files that should be affected by the attribute change. 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 specify files matching a certain mask. Multiple file and/or file masks may be specified by separating the entries with a pipe symbol (|).

Attributes

Options

Yes

(Empty)

  1. ATTRIBUTES="+A+H"(archive, hidden attrib on)

  2. ATTRIBUTES="-S-H"(system, hidden attrib off)

  3. ATTRIBUTES="-R-A+S+H"(read-only and archive attrib off, system & hidden attrib on)

The attribute combination that the file(s) should be modified to. In visual mode simply select from the drop-down lists. In AML mode, use the RASH attribute system as outlined below.

Create and Populate Dataset

Text

No

(Empty)

RESULTDATASET="DatasetName"

The name of a dataset to be created and populated with the results of this operation. More information about the fields this dataset are entered below under Datasets.

File Parameters

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.

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

 

 

 

 

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 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 Parameters

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 copied 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 act on. 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 tuAttributesrned 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 tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

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.

RASH File Attributes - Overview

File attributes can be specific characteristics or certain permissions set for a file. Every file on your hard disk has one or more attributes; usually, these attributes are turned on and off by system components or external applications. The Set Attributes action allows you to set the attributes if one or more files. Moreover, many file-related actions include attribute properties allowing a way to filter which files worked on based on the current attribute settings of the source file(s). Up to four attributes can be assigned to each file at any one time. They start with the letters R, A, S, H.

R - Read-Only - Files with this attribute cannot be overwritten or erased by standard programs or users.

A - Archive - A system or program uses this attribute to determine which files changed since they were last copied or backed up. Similarly, backup programs like Seagate Backup Exec, Microsoft Backup, etc. all use this attribute to handle what files need to be backed up.

S - System - A file with this attribute is usually one that is an integral part of your operating system. This attribute has a special meaning for DOS and Windows systems.

H - Hidden - A file having this attribute cannot be seen by a normal DOS directory search or cannot be seen if Windows Explorer or similar programs aren't specifically set up to see them.

In visual mode, a group of controls are provided to assist in setting attributes for a file.

The available options are:

  • Do not modify - no actions taken (default)

  • Turn On - Turn on attribute

  • Turn Off - Turn off attribute

In markup mode, a single text item must be specified that contains the attributes of the files you wish to modify.

To turn an attribute on/off, use the + and - sign (+ = Turn on attribute, - = Turn off attribute) For example:

  • Use +R to turn on the read-only attribute and - R to turn it off. Not specifying R as a part of the text would ignore it.

  • Use +A to turn on the archive attribute and - A to turn it off. Not specifying A as a part of the text would ignore it.

To change several attributes in a single pass, simply put them together. For example:

  • +R-A-S+H would turn on the read-only and hidden attributes and turn off archive and system.

  • +R+S+H would turn on the read-only, hidden, and system attributes. Archive would be left as is.

Examples

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

Example 1: Set Attributes for file(s) "c:\myfile.txt".  System on.  

<AMSETATTRIBUTES SOURCE="c:\myfile.txt" ATTRIBUTES="+s" />

Example 2: Set Attributes for file(s) "C:\SourceFolder\*.*".  Exclude the file mask(s) "*.pri".  Archive on.  Include sub folders.  Only if older than "2/26/2007 11:41:46 PM".  Only if system is not set.  Only if hidden is not set.  Create and populate dataset "SetAttrDataset" with query results.  

<AMSETATTRIBUTES SOURCE="C:\SourceFolder\*.*" SUBFOLDERS="YES" 
ISOLDERTHAN="%DateSerial(2007,02,26) + TimeSerial(23,41,46)%" 
ATTRIBUTES="+a" ATTRFILTER="-s-h" EXCLUDE="*.pri" 
RESULTDATASET="SetAttrDataset" />