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 a combination of the following (the same values as on Windows):
Value Meaning $1 Read-only (no write permission) $2 Hidden file or directory (has the Finder hidden flag, or the name starts with ".") $10 Directory $20 Regular file $400 Symbolic link
Example
file = '/Users/user/test.txt' getfileattr file if result <> -1 then if result & $1 > 0 then messagebox 'This file has readonly attribute.' file endif endif
name = "/Users/user/test" getfileattr name if result < 0 then messagebox "Not found" name elseif result & $10 then messagebox "Directory" name else messagebox "File" name endif