Synopsis:
Does a check on the specified file (NEW in Asterisk 1.4)Description:
STAT(<flag>,<filename>)flag may be one of the following:
- d: Checks if the file is a directory
- e: Checks if the file exists
- f: Checks if the file is a regular file
- m: Returns the file mode (in octal)
- s: Returns the size (in bytes) of the file
- A: Returns the epoch at which the file was last accessed
- C: Returns the epoch at which the inode was last changed
- M: Returns the epoch at which the file was last modified
Notes
- *CLI> show function STAT

Comments
333usage with comparison operator
when STAT() is used in an expression inside a GotoIf, you can get the wrong result if you do a string comparison of a numeric return value.
So take a numeric return value, make sure it is non-zero and then use it in a comparison expression.
Eg. 2 > 1 is TRUE but "2" > "100000000" is also true
See below
exten => s,1,Set(filexist=${STAT(e,path-to-sound-file.ul)})
exten => s,n,Set(filesize=${STAT(s,path-to-sound-file.ul)})
exten => s,n,Set(filesize=$[${filesize} + 1])
exten => s,n,GotoIf($["${filexist}" = "1" & ${filesize} > 1]?use_sound:use_default)