List the files in a folder.
Built-in Function handler
put files([<targetFolder>, [detailed|detailed-utf8]])
put the [short|long] files
put files(specialFolderPath("documents")) into field "Current Docs" sort lines of field "Current Docs" international
repeat for each line tFileInfo in the detailed files add item 3 of tFileInfo to tTotalSize end repeat answer merge("The files in the current folder use " & tTotalSize &" bytes")
put the files & return & the folders into diskContents[the defaultFolder] filter diskContents[the defaultFolder] without ".."
put files(tTargetFolder, "detailed-utf8") into tTheFiles
Return a list of files in the targetFolder, with one file per line. If no targetFolder is specified, list the files in the current folder.
Folders are not included in the list. To get a list of folders, use the folders function.
Aliases (on OS X systems), symbolic links (on Linux systems) and shortcuts (on Windows systems) are included in the list only if they refer to a file.
The order that files are listed is platform-dependent. The order may vary between platforms, between filesystems, and even between consecutive calls to the files function. If you need a sorted list, use the sort command.
When the files is called as a function, or without the long or detailed modifiers, it returns only the file names as a string with one file name per line.
the long files and the detailed files are synonyms. When the files function is called in this form, the return value is a list of files with detailed file attributes.
Each line in the return value is a comma-separated list of file attributes, as follows:
- Name. The file name is URL-encoded. To obtain the name as plain text, use the URLDecode function.
- Size, in bytes. On OS X systems, this is the size of the data fork.
- Resource fork size, in bytes. (OS X only).
- Creation date, in seconds. (OS X and Windows only).
- Last modification date, in seconds.
- Last access date, in seconds.
- Last backup date, in seconds.
- User owner. (Linux and OS X only).
- Group owner. (Linux and OS X only).
- Permissions. (Linux and OS X only; see note).
- Creator and file type (OS X only).
Any attribute that is not relevant to the current platform is left empty.
The access permissions consist of three octal digits, in the same form used for the umask property.
On Windows, the permissions are always reported as "777".