# getfileattr

Returns the attributes of a file or directory.

    getfileattr <filename>

## Parameters

string <filename>
  The file name or directory name

## Return Value

System variable <result>
  When this command fails, -1 is stored.
  When the command succeeds, the returned value is in the following:

  Value | Meaning
  --- | ---
  $1 | Read only
  $2 | Hidden
  $4 | The operating system uses a part of, or uses exclusively
  $10 | Directory
  $20 | Archive
  $80 | Not have other attributes set
  $100 | Temporary
  $200 | Sparse file
  $400 | Has an associated reparse point, or a file that is a symbolic link
  $800 | Compressed
  $1000 | Physically moved to offline storage(Windows 2000 or later)
  $2000 | Not to be indexed by the content indexing service(Windows 2000 or later)
  $4000 | Encrypted

## Example

    file = 'c:\test.txt'
    getfileattr file
    if result <> -1 then
    	if result & $1 > 0 then
    		messagebox 'This file has readonly attribute.' file
    	endif
    endif

    name = "C:\test"

    getfileattr name

    if result < 0 then
    	messagebox "Not found" name
    elseif result & $10 then
    	messagebox "Directory" name
    else
    	messagebox "File" name
    endif

## See also

- setfileattr
- MSDN Library GetFileAttributes
- MSDN Library File Attribute Constants