• 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: Selecting a folder from the sidebar in a save dialog
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selecting a folder from the sidebar in a save dialog


  • Subject: Re: Selecting a folder from the sidebar in a save dialog
  • From: Joe <email@hidden>
  • Date: Tue, 11 May 2010 15:50:16 -0700

At 4:02 PM -0500 5/11/10, Jim Brandt wrote:
>I am already GUI scripting Safari. I have to open a URL and find links on that page. To do that, I'm saving the source of the page (via GUI scripting - command-option-U to view the source then command-S to save it). This creates a save dialog that I then use to name the file and select the location to save it. It just so happens that the location I want to save the file at is on the sidebar, so I can currently click it, via the command I showed earlier. These scripts have been working for me for a couple years now.

I think I would abandon the GUI approach.

tell application "Safari"
 set x to source of document 1 --get the doc source into a variable
end tell

>My dilemma is that I now need this script to work on two different operating systems (Tiger 10.4.11 and Snow Leopard 10.6.3) where the dialog, specifically as it relates to picking the folder from the sidebar, is not the same. Not only that, but "To_Be_Sent", while it exists as a folder on both machines, is NOT in the same location. If "To_Be_Sent" is a sidebar item on both machines, the scripting should be similar, even if the folder is located on completely differently named drives on the two machines.
>
>If I hard-code the path, I'll have to maintain separate versions of the script on each machine. But even at that, I don't see how to tell the save dialog to use that definition to save the file.

name the file

set the y to the text returned of (display dialog "name it" default answer "")

Write the file to disk

  set myfile to "Path:to:folderInSidebar:" & y & ".txt"
  try
    close access file myfile
  end try
 set fileReference to open for access file myfile with write permission
  write (x as string) to fileReference starting at eof
  close access fileReference


Putting it all together

tell application "Safari"
 set x to source of document 1 --get the doc source into a variable
end tell
set the y to the text returned of (display dialog "name it" default answer "")
  set myfile to "Path:to:folderInSidebar:" & y & ".txt"
  try
    close access file myfile
  end try
 set fileReference to open for access file myfile with write permission --creates the file
  write (x as string) to fileReference starting at eof
  close access fileReference

 _______________________________________________
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

References: 
 >Re: Selecting a folder from the sidebar in a save dialog (From: CYB <email@hidden>)
 >Re: Selecting a folder from the sidebar in a save dialog (From: Jim Brandt <email@hidden>)

  • Prev by Date: Scripting Bridge usage, iPhoto example
  • Next by Date: Re: Selecting a folder from the sidebar in a save dialog
  • Previous by thread: Re: Selecting a folder from the sidebar in a save dialog
  • Next by thread: Re: Selecting a folder from the sidebar in a save dialog
  • Index(es):
    • Date
    • Thread