There are several different ways of referring to files and folders and their locations, which can be useful under different circumstances. The two standard ways used by the AppleScript language are the “alias” and the “file specification”. These can both refer to files, folders, or volumes. They look very similar on the page, but their compiled data are different.
alias “My HD:Users:me:Desktop:My file.txt”
This is understood (or should be) by scripts, OSAXen, and scriptable applications alike. The item must exist when the alias is created, otherwise an error will occur. (In the above form, the alias is created when the script’s compiled.) If the item’s subsequently moved, the alias will track it.
file “My HD:Users:me:Desktop:My file.txt”
This should also be universally understandable. Although the keyword ‘file’ is used, it can also refer to a folder or a disk. The item needn’t exist when the file specification is created. If the item does exist and is moved, the file specification will still point to the original location, not to the moved item.
There are also “paths”. HFS paths look similar to aliases and file specifications; but paths are just text. However, they’re increasingly recognised and interpreted as file references nowadays by many functions and applications.
“My HD:Users:me:Desktop:My file.txt” – No ‘alias’ or ‘file’ keyword. This is the standard Mac OS path format.
“/Users/me/Desktop/My file.txt” – This is the Unix path format, for use in shell scripts and with certain non-standard applications.
Some applications have their own reference forms for disk items, notably the Finder and System Events. Unfortunately, only they understand their own references, although they also understand aliases, file specifications, and (usually) HFS paths. The Finder reference for the above file could be written in a number of ways:
file “My file.txt” of desktop
file “Desktop:My file.txt” of home
file “Users:me:Desktop:My file.txt” of startup disk
file “My HD:Users:me:Desktop:My file.txt” – Inside a Finder ‘tell’ block, this is a Finder reference, not a file specification.
If “My file.txt” were a folder instead of a file, you’d have to use folder instead of file in the Finder reference. Alternatively, you could use the non-specific item in place of either of these.
Writing as alias after a Finder reference causes the Finder to return an alias instead of one of its own references. This alias can be understood and used by another application or by something else in the script.