Here’s a few of the AppleScript handlers I use for getting contents of folders (examples 1 & 2), or for getting the text of a file (example 3).
In all three cases, you give the handler a path string in POSIX form, e.g, ~/Desktop or (for example 3), ~/Desktop/sometext.txt.
In example 1, what you get back is a list of the item names in the folder. It doesn’t include hidden or invisible files.
In example 2, what you get back is a record of all the items and their properties. This can be an immensely useful and powerful handler.
In example 3, what you get back is a text variable whose value is the complete text of the file.
Hope these come in as handy for you folks as they have for me!
Click here to get the handlers from my pastebin.
Note: The getFileContents() handler requires OSX 10.10 or higher.