Question

In my Applescript, I'm choosing a file of which I would like to store the path (to be opened later).

When I tried storing the path of the file as a string, this is the error I received:

error "Can’t make path of alias \"Macintosh HD:Users:Username:Desktop:Folder:File.xls\" into type string." number -1700 from path of alias "Macintosh HD:Users:Username:Desktop:Folder:File.xls" to string

How can I effectively store this file path, so that I may recall it later when opening this file?

Applescript:

tell application "Finder"
    set filePath to path of (choose file) as string
    set fileName to name of file filePath
end tell

*Note: I also tried as text.

Was it helpful?

Solution

This seems to work:

tell application "Finder"
    set filePathAlias to (choose file)
    set fileName to name of filePathAlias
    set filePath to filePathAlias as string
end tell
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top