Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7809573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:29:00+00:00 2026-06-02T03:29:00+00:00

In an applescript, I receive one filepath that I’ve to open. The filepath is

  • 0

In an applescript, I receive one filepath that I’ve to open.

The filepath is in the format “/Users/xxx/my/file/to/open.xyz“.

I want to open it with the default program. If it’s an AVI, I need to open it with a video program, if it’s an xls, with excel, …

I tried several things without any success:

--dstfile contains the previous path
tell application "Finder"
    activate
    open document dstfile
end tell

–>I’m getting the error 1728, telling me that he wasn’t able to get the document

tell application "Finder"
    activate
    open document file dstfile
end tell

–> Same here

tell application "Finder"
    activate
    open document POSIX file dstfile
end tell

–> Same here

I’m sure that the file exists because I do this before this code execution:

if not (exists dstfile) then
    display dialog "File isn't existing"
end if

I cannot use the synthax open.xyz of to of… because I receive this as a parameter.

Please help I’m desperate :'(

Answer: Based on answers, I end up with this:

set command to "open " & quoted form of dsturl
do shell script command
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:29:01+00:00Added an answer on June 2, 2026 at 3:29 am

    Your problem here is twofold:

    1. your path is in POSIX notation, which AppleScript cannot coerce to an alias or file object acceptable to the Finder, as these will only be implicitly created from path strings in HFS notation (Users:xxx:my:file:to:open.xyz). Expressly declaring your path as POSIX file will solve this. However,
    2. your call to Finder prefixes document to the path, but Finder’s AppleScript dictionary does not contain a document object type (there is a document file object, but it is a child of finder item which cannot be created in this call). Removing that part will solve the issue.

    TL;DR: the following line will open a file given through a POSIX path in the default program without recourse to the shell:

    tell application "Finder" to open POSIX file "/Users/xxx/my/file/to/open.xyz"
    

    Caveat: this is the simplest solution, but it will only work for qualified POSIX paths (i.e. those beginning with /), like the one in the question. Handling relative ones (i.e. paths starting with ~, . or ..) OTOH needs either the AppleScript-ObjectiveC API (not exactly trivial) or the shell (have fun with your quoting).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of AppleScript scripts in a directory that I want to
I tried to create an AppleScript that reads a text file and puts the
I have an applescript that gets a string at one point and checks if
Want an applescript droplet that opens files in QuickTime and mutes them all. The
Hi I have written applescript to get file name. on open of thisPDF set
I am creating an applescript that creates a backup image of the /Users folder
I have an applescript that reads data from a CSV (successfully!). After my script
Is it correct that the reveal applescript command is broken with iTunes 9? Works:
Any way to bind an applescript to iTunes so that when iTunes is started
I am creating an application using AppleScript and I want to display a list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.