Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to open a file or image in applescript

I know this might be a simple task for some people who are used to this software, but I am still learning about it through the apple site and other sites. I am in fact able to open a window in finder or open a window in a web browser that leads you to a website, but I am not able to open an image or file. Is the code at all similar to opening a website? If this is not even possible to do in the current version of applescript then please tell me, or if it is again please answer.

MacBook Air, iOS 10.1.1

Posted on Nov 24, 2016 6:44 PM

Reply
Question marked as Best reply

Posted on Nov 25, 2016 9:04 AM

tell application "Finder"

open file "Macintosh HD:Users:barney:Pictures:file name.png"

end tell


This will tell Finder to open the file with the default app.

You can also tell a specific app to open a file in the same way.


If you want to edit a text file within AppleScript (or just read the text), you have to "open for access" and then close the file when done editing. http://faqintosh.com/risorse/en/guides/as/guide/fileIO/

Note that tutorial shows you how to use unix paths instead of the old Classic Mac OS path as shown above.

4 replies
Question marked as Best reply

Nov 25, 2016 9:04 AM in response to Barner Konvicka

tell application "Finder"

open file "Macintosh HD:Users:barney:Pictures:file name.png"

end tell


This will tell Finder to open the file with the default app.

You can also tell a specific app to open a file in the same way.


If you want to edit a text file within AppleScript (or just read the text), you have to "open for access" and then close the file when done editing. http://faqintosh.com/risorse/en/guides/as/guide/fileIO/

Note that tutorial shows you how to use unix paths instead of the old Classic Mac OS path as shown above.

How to open a file or image in applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.