Javascript FileSystemObject (FSO) provides Attributes property that can be accessed through file object or folder object returned by the GetFile method or GetFolder methods. Both these methods allow the access to Attributes property that returns the attributes of the specified file or folder. Attributes property provides the functionality to get or set the attributes of the specified file or folder for example: read-only property, hidden file property, System files property etc.

Syntax for Javascript FSO Attributes property

fileObj.Attributes

// or
folderObj.Attributes

Both above syntaxes show the way of using the file object and folder object to access the Attributes property. GetFile method returns the file object and GetFolder method returns the folder object that can be used to access the Attributes property associated with the specified file or folder. You can the Attributes property to get or set the attribute properties of file or folder. Following are the value that can be retrieved or assigned to the attributes property:

0 = value for normal file

1 = value for read-only file

2 = value for hidden file

4 = value for System file

16 = value for Folder

32 = value for modified file

1024 = value for shortcut

2048 = value for compressed file or folder

Example of Javascript FSO Attributes Property

<script type="text/javascript">
    // initialize ActiveXObject and create an object of Scripting.FileSystemObject.
    var fso = new ActiveXObject("Scripting.FileSystemObject");

    // object created for file object returned by GetFile method
    var fileObj = fso.GetFile("C:\\Temp\\textFile.txt");

    document.write("<b>File Attribute: </b>" + fileObj.Attributes);

    document.write("<br />");

    // object created for folder object returned by GetFolder method
    var folderObj = fso.GetFolder("C:\\Temp\\myFolder");

    document.write("<b>Folder Attribute: </b>" + folderObj.Attributes);

    document.write("<br />");

    fso = null;

    // Output: 
    // File Attribute: 32 
    // Folder Attribute: 16
</script>

Continue to next tutorial: Javascript FSO DateCreated Property to learn how to get the creation date of the specified file or folder.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.