Skip to content

Instantly share code, notes, and snippets.

@miyagawa
Last active August 29, 2015 14:13
Show Gist options
  • Save miyagawa/a70892a0b0ca2f570ae2 to your computer and use it in GitHub Desktop.
Save miyagawa/a70892a0b0ca2f570ae2 to your computer and use it in GitHub Desktop.
-- 1. TextEdit got an error: Can’t get POSIX file "..."
set p to "/path/to/file.txt"
tell application "TextEdit"
set q to POSIX file p
end tell
-- 2. This works
tell application "TextEdit"
set q to POSIX file "/path/to/file.txt"
end tell
-- 3. This works
set p to "/path/to/file.txt"
tell application "TextEdit"
set q to (p as POSIX file)
end tell
-- 4. This works
set p to "/path/to/file.txt"
set q to POSIX file p
@johneday
Copy link

johneday commented Jan 7, 2015

posix file belongs to standard additions. When possible, don't include it in a tell block.

set p to "/path/to/file.txt"
set q to POSIX file p
tell application "TextEdit" to open q

@miyagawa
Copy link
Author

miyagawa commented Jan 8, 2015

Yeah I got the lesson out of this - the thing that drives me nuts is that it sometimes works and sometimes doesn't!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment