AppleScript to open file using Finder

I have a csv file in Downloads folder. Before updating to 12.3, I used the following script to open the file:


set f1 to "MacSSD:Users:Myname:Downloads:test.csv" as string

tell application "Finder" to open f1


After the 12.3 update, the script doesn't work. It opens the Numbers app without any window. I have to tell Finder again to open the file:


set f1 to "MacSSD:Users:Myname:Downloads:test.csv" as string

tell application "Finder"

if application "Numbers" is running

open f1

else

open f1

delay 1

open f1

end if

end tell


I used the if loop to avoid duplicates in case the Numbers app is running in the background.


I like my old script. It was much simpler. Any idea why it is not working anymore?


I know that I could tell the Numbers app to open the file, but then it opens a blank document which I don't want.

Mac mini 2018 or later

Posted on Mar 26, 2022 1:31 PM

Reply

Similar questions

4 replies

Mar 26, 2022 8:32 PM in response to 70s_oldtimer

I'm running 12.3


This works here:


set f1 to "MacIntosh HD:Users:UserName:Downloads:test.csv"
tell application "Numbers" to open f1


This does too:


set f1 to "MacIntosh HD:Users:UserName:Downloads:test.csv"
tell application "Finder" to open f1


(The name of my drive is not MacSSD but MacIntosh ID.)


So the problem appears to be specific to your configuration. Some setting may have gotten changed when you updated to 12.3.


If you haven't already you may want to double-check the path to your Downloads folder.


Also check System Preferences > Privacy & Security > Privacy > Accessibility to make sure you've set all the needed permissions to control your computer (e.g., if your running the script in Script Editor make sure Script Editor.app is listed and checked there, etc.).


SG



Mar 27, 2022 6:56 AM in response to SGIII

set f1 to "MacIntosh HD:Users:UserName:Downloads:test.csv"

tell application "Numbers" to open f1


gives me an error: "test.csv" can't be imported. The file couldn't be opened.


set f1 to "MacIntosh HD:Users:UserName:Downloads:test.csv"

tell application "Finder" to open f1


works if I repeat the tell statement, i.e. run the script twice.


I looked at the System Preferences, "Script Editor" was checked. I toggled the selection, restarted the computer, selected "Script Editor" again but nothing changed.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript to open file using Finder

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