Cannot open a file with AppleScript
I'm following the same instruction as listed on this page and yet I cannot open this text file
tell application
"TextEdit" open file "Macintosh HD:Users:kylefoley:codes:byu_docs:dictionaries:first_name_research:btn_tree_start_r.rtxt"
end tell
The error message I'm getting is: Expected “given”, “with”, “without”, other parameter name, etc. but found class name.
Ultimately I need to be open it with a python script. So when I use Python I get a different error message:
file='Macintosh HD:Users:kylefoley:codes:byu_docs:dictionaries:first_name_research:btn_tree_start_r:Jaxson.rtxt'
os.system(
... f'''/usr/bin/osascript -e
... 'tell application
... "TextEdit" open file "{file}"
... end tell' ''')
/usr/bin/osascript: option requires an argument -- e
usage: osascript [-l language] [-e script] [-i] [-s {ehso}] [programfile] [argument ...]
sh: line 3: tell application
"TextEdit" open file "Macintosh HD:Users:kylefoley:codes:byu_docs:dictionaries:first_name_research:btn_tree_start_r:Jaxson.rtxt"
end tell: command not found
I should also add that I'm certain the file exists because when I put in a bogus file I get the following error message: No such file or directory
MacBook Pro 15″, macOS 10.12