(choose file) as string
When using the “choose file” command (shown above), if the file you choose is a package (numbers, pages, and probably all or most of the “i-apps”) the path returned will appear as a folder (ending with a colon “:”) rather than a file. This will cause an error if you later try to get a property of or manipulate the file.
To get around this problem, you can add a couple of lines of code to detect and remove the colon from the file path before proceeding further as follows:
set pathToFile to (choose file) as string
if pathToFile ends with ":" then set pathToFile to text 1 thru -2 of pathToFile as string
This problem exists in 10.5 and may also exist in previous versions of OS X.