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)
  • SOURCE="c:\sourcefolder\file.txt"

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

  • 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). You can use wildcard characters (for example, * or ?) to specify all files matching a certain mask. You can specify multiple files and file masks 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)
  • ATTRIBUTES="+A+H"(archive, hidden attrib on)
  • ATTRIBUTES="-S-H"(system, hidden attrib off)
  • 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, specifies that, if present, subfolders should be searched for files matching the mask specified in the File A and/or File B parameters. This parameter is disabled by default.
Exclude mask Text No (Empty)
  • EXCLUDE="*.txt"
  • EXCLUDE="*.txt|*.bak"
  • EXCLUDE="c:\foldename"
Causes this activity to omit 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).
Regular expression Yes/No No No RE="yes" If selected, indicates that any value entered in the Exclude mask parameter will be interpreted as a regular expression. If disabled (default) the value will be interpreted as normal readable text.
Only if newer than Date No (Empty) ISNEWERTHAN="%DateSerial(2001,10,12) + TimeSerial(00,00,00)%" If enabled, causes this activity 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 Doesn't matter ATTRFILTER="+R+A-H" (compress read-only & archive files but not hidden files) Instructs the activity to filter which files to act on, based on whether the file's original attribute settings match the attribute settings specified in this parameter. In Task Builder's visual mode, drop-down boxes are provided within the activity's settings to assist in the selection of attribute settings. In Task Builder's AML mode, a text item must be entered that contains the original attribute mask of the files you wish to affect. For example, if Read-only attribute is set to Off (in visual mode) or -R (in AML mode) , only source files with the Read-only attribute turned off are affected. Source files with Read-only attribute turned on will be ignored. The available options are:
  • Read-only attribute is - Specifying On or +R includes files with this attribute turned on. Specifying Off or -R includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • Archive attribute is - Specifying On or +A includes files with this attribute turned on. Specifying Off or -A includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • System attribute is - Specifying On or +S includes files with this attribute turned on. Specifying Off or -S includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • Hidden attribute is- Specifying On or +H includes files with this attribute turned on. Specifying Off or -H includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • Compression attribute is - Specifying On or +C includes files with this attribute turned on. Specifying Off or -C includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.
  • Encrypted attribute is - Specifying On or +E includes files with this attribute turned on. Specifying Off or -E includes files with this attribute turned off. Specifying Doesn't matter (default) or excluding the letter ignores this attribute.

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:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

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