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

Related Topics    

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 under Notes.

Parameters

General

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 to use to be affected by the attribute change. This can be a fully qualified path and file name (preferred) or a single file (requires use of the File System - Change folder activity). Wildcard characters (for example, * or ?) may be used to specify all files matching a certain mask. Multiple files and/or file masks can be specified by separating each entry with a pipe character (|) (for example, c:\temp\*.txt|c:\backup\*.bak). See File Masks & Wildcards for more details.

NOTE: Files with invalid paths are ignored at runtime.

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 files 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 Options

Property

Type

Required

Default

Markup

Description

Include subfolders

Yes/No

No

No

SUBFOLDERS="YES"

If selected, denotes that, if present, subfolders should be searched for files matching the mask specified in the Source parameter. If disabled (default value), subfolders are altogether ignored.

Exclude mask

Text

No

(Empty)

EXCLUDE="*.txt"

Causes this action to omit files matching the masks 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

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

Additional Notes

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 files. 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

NOTE:
  • The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

Example 1

Set Attributes for files "c:\myfile.txt".  System on.

Copy
<AMFILESYSTEM ACTIVITY="set_attributes" SOURCE="c:\myfile.txt" ATTRIBUTES="+s" />

Example 2

Set Attributes for files "C:\SourceFolder\*.*".  Exclude the file masks "*.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.  

Copy
<AMFILESYSTEM ACTIVITY="set_attributes" SOURCE="C:\SourceFolder\*.*" ATTRIBUTES="+s" SUBFOLDERS="YES" EXCLUDE="*.pri" ISOLDERTHAN="%DateSerial(2019,12,09)+TimeSerial(11,43,23)%" ATTRFILTER="+a-s-h" />