• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can't get the change download folder in Safari script to work - ui scripting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't get the change download folder in Safari script to work - ui scripting


  • Subject: Re: Can't get the change download folder in Safari script to work - ui scripting
  • From: Luther Fuller <email@hidden>
  • Date: Sun, 13 Mar 2011 14:24:31 -0500

On Mar 13, 2011, at 10:30 AM, Tommy Bollman wrote:

Hello. I have som problems with Getting the  block marked #!? to work,
I'm using Safari v.5.03 and I think that the layaout of the ui-elements has changed some.

Never use UI scripting unless you absolutely, positively have to.

I just could not resist finding a non-GUI solution to this.
The location of Safari's downloads folder is stored in Safari's
preference file "com.apple.Safari.plist" in the key "DownloadsPath".

All you have to do is write a new value to this key. Here's the script ...

on run
set DLFolderAlias to my getDownloadFolder()
my setSafariDLFolder(DLFolderAlias)
beep
end run --------------------

on getDownloadFolder()
set pText to "Choose a new download folder for Safari ..."
set DLFolder to choose folder with prompt pText default location (path to desktop) -- error -128 on cancel
return DLFolder -- an alias
end getDownloadFolder --------------

on setSafariDLFolder(folderAlias)
set folderPath to (POSIX path of folderAlias)
set prefsFolder to (path to preferences folder from user domain)
tell application "Finder" to set prefsFile to (file "com.apple.Safari.plist" of prefsFolder) as alias
tell application "System Events" to set infoRecord to value of property list file (prefsFile as text) -- READ
set infoRecord to {DownloadsPath:folderPath} & infoRecord -- MODIFY
tell application "System Events" to set value of property list file (prefsFile as text) to infoRecord -- WRITE
end setSafariDLFolder ---------------

And, yes, I did try it and it worked.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Can't get the change download folder in Safari script to work - ui scripting
      • From: Tommy Bollman <email@hidden>
References: 
 >Can't get the change download folder in Safari script to work - ui scripting (From: Tommy Bollman <email@hidden>)

  • Prev by Date: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Next by Date: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Previous by thread: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Next by thread: Re: Can't get the change download folder in Safari script to work - ui scripting
  • Index(es):
    • Date
    • Thread