title: Download a File through Safari with AppleScript
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>So I guess the question breaks down to:</p>
  
  <ol>
  <li>How do I <code>tell application "Safari"</code> to download a file?</li>
  <li>Can I specify where it saves the file?  Or can it only go to the <code>Downloads</code> folder?</li>
  <li>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?</li>
  </ol>