8.5.16 SetFileAttribute or SetFileAttr (set folder or file attributes)
- Purpose
-
Sets folder or file attributes.
In JP1/Script 07-50 or later, the command supports large files.
- Syntax
SetFileAttribute (PathName, Attribute1 [, Attribute2, ...]) SetFileAttr (PathName, Attribute1 [, Attribute2, ...])
- Arguments
-
- PathName
-
Write the full path of the folder or file for which the attribute is to be set. Specify a character string or a variable that stores this value.
- Attribute1 to Attribute8
-
Specify one or more of the following attributes. If you specify ATTR_NORMAL, you cannot specify any other attributes.
Value
Meaning
ATTR_READONLY
Read-only file
ATTR_HIDDEN
Hidden file
ATTR_ARCHIVE
Archive file
ATTR_SYSTEM
System file
ATTR_TEMPORARY
Temporary file
You cannot specify this attribute if you specify a folder in PathName.
ATTR_NORMAL
Overrides all other attributes. This attribute can only be specified alone.
To add or remove only the attributes that you set in Attribute1 to Attribute8 for the folder or file specified in PathName, write either of the following values:
Value
Meaning
ATTR_ON (from version 05-10)
Add only the attributes set in Attribute1 to Attribute8.
ATTR_OFF (from version 05-10)
Remove only the attributes set in Attribute1 to Attribute8.
In JP1/Script 06-00 and later versions, you can set multiple attributes by specifying a one-dimensional array variable that stores each of the attributes.
- Description
-
The SetFileAttribute or SetFileAttr command sets one or more attributes for the specified folder or file. The command returns True on successful execution, or False if an error occurs.
To acquire the attributes of a folder or file, use the GetFileAttribute command. To check one attribute of a folder or file, use the IsFileAttribute command.
- Note
-
Take care when specifying the folder, or a folder or file in the folder set in the following environment variables: ProgramFiles (normally the Program Files folder on the system drive) and WinDir (normally the Windows folder on the system drive). For details, see 1.8.3 Effect of the executing user on command behavior.
- Example
' Delete the archive attribute of a file. After accessing ' the file, check the archive attribute for file updates. Dim file1 file1 = "C:\TEMP\logging.tmp" If IsFileAttribute (file1 ,ATTR_ARCHIVE) = True Then SetFileAttribute (file1 ,ATTR_ARCHIVE ,ATTR_OFF) End ... (File access operations) ... If IsFileAttribute (file1 ,ATTR_ARCHIVE) = True Then MessageBox (file1+ "has been updated.") Else MessageBox (file1+ "was not updated.") End
- JP1/Script version
-
Supported from JP1/Script 01-00.