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

  • SEARCH
  • Home
  • 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 6536035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:26:37+00:00 2026-05-25T10:26:37+00:00

For reasons I won’t really go into, I need to write something in AppleScript

  • 0

For reasons I won’t really go into, I need to write something in AppleScript which will download some files specifically through Safari. (Just something that someone will double-click to run which will open Safari and show them a web page while initiating some downloads.) I can set the URL of the document with AppleScript, but that doesn’t download the file. It’s a file that Safari thinks it understands, so it just tries to open it directly. I need the file to be downloaded to the file system.

Everything I find on Google mentions something called “URL Access Scripting” but when I use that the AppleScript editor asks me to select what application it is, which I don’t seem to have (or don’t know where it is). Other suggestions are to call command line tools to download the file, but the issue here is apparently that the user has some cookie(s) in Safari that authorize them to the server resource, so the command-line tools will just get an error.

So I guess the question breaks down to:

  1. How do I tell application "Safari" to download a file?
  2. Can I specify where it saves the file? Or can it only go to the Downloads folder?
  3. Alternatively, can I configure Safari to not try to open certain file types so that maybe I just loop through the file URLs in the document before showing the page?
  • 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-05-25T10:26:38+00:00Added an answer on May 25, 2026 at 10:26 am

    AppleScript itself cannot force Safari to download files.
    Currently I can imagine two ‘hacky’ alternatives:

    1. Initiate the download using JavaScript. (Google for the actual script.)

    tell application "Safari"
        do JavaScript " alert('AppleScript successfully executed.');" in document 1
    end tell
    

    2. Open the Safari download manager through GUI scripting and paste the URL.
    (Make sure to enable assistive devices.)

    tell application "Finder" to set the clipboard to "http://www.google.nl/favicon.ico"
    tell application "System Events"
        tell application "Safari" to activate
        keystroke "l" using {command down, option down}
        keystroke "v" using command down
    end tell
    

    AppleScript cannot specify where to download specific files,
    it can however change the default downlaod location:
    (Make sure the path exists and relaunch Safari.)

    do shell script "defaults write com.apple.safari DownloadsPath -string \"/Users/Anne/Desktop\""
    

    AppleScript can indeed disable the “Open safe files after downloading” feature:
    (Make sure to relaunch Safari.)

    do shell script "defaults write com.apple.Safari AutoOpenSafeDownloads -boolean NO"
    

    Safari now automatically downloads PDF files.
    Unfortunately images are still being displayed.

    Conclusion

    AppleScript itself simply cannot achieve your goals.

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

Sidebar

Related Questions

For reasons I won't go into, I need a COM-based tree control with the
For reasons I won't go into I need to use CLR generics syntax in
For reasons I won't go into, I wish to ban an entire company from
Basically I'm trying to proxy some web services locally (for reasons I won't go
For various reasons that I won't go into (I promise it's necessary to do
From reasons I won't get into, all our unit tests are using the VSTS
For reasons I won't get into I'm forced to configure a log4j appender programmatically.
I am binding a Winforms Grid to an entity. (For reasons I won't go
For reasons that we won't discuss, I have determined that MAMP is a pile
For some reason This php script won't echo anything: <?php setcookie(pop,'hi',time()+604800); echo $HTTP_COOKIE_VARS['pop']; ?>

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.