Improved Capture from Safari?

I like the script to capture pages from Safari, but I need something more robust:

I’d like to be able to choose what folder the resulting file is saved in, even creating a new subfolder if one doesn’t exist.

Is this possible?

Also, any suggestions as to how I can map an AppleScript to a key-sequence so that I can do this faster?

Red Sweater Software has a program called Fastscripts that allows you to assign a custom keyboard shortcut to any script. See

I’ve adapted the “Copy Selection to Incoming” script (in the “Additional” folder on the Disk Image) to do just this. By changing the destination in the script thus:

tell application "DEVONthink Pro"
set incomingGroup to create location "Personal/PersonalInbox"
paste clipboard to incomingGroup
end tell

```I've just created separate scripts for my favorite destinations. 

Alternately, you can just use the "Copy Selection to..." script which works great and lets you choose your destination.

As for Keyboard commands: OS X's own Keyboard Shortcuts (Under System Preferences/Keyboard & Mouse) work just fine with scripts.

Hope this helps,


Can anyone suggest how to modify the script so the capture uses the web archive method instead of html?

Also, is there a way to convert existing html files (or urls) to web archives?


That’s currently impossible as Safari 1.3/2.0 does not provide access to web archive data via AppleScript (contrary to DEVONagent for example).

It seems like it could be easily done with an apple script that told safari to open the selected html files and then save them as a webarchive of the same name.

Alternatively, you could do just that manually or perhaps use automator to do the same.

I have wanted to learn applescript for some time now but can’t seem to find the time (full time PhD student, full time work, getting married next year, currently moving…)

Is there a way to create a script in DevonThink that will convert a html page to web archive?
(Reload the html page, Capture Web Archive, Delete the html page).
I tried playing around with Applescript using the GUI scripting ability, but I couldn’t figure out how to do this
Has anyone else used this approach successfully?

There are a lot of things that I do repetively in DevonThink that I would like to script in some way


Thanks. The “copy selection to…” and “copy selection to incomming” scripts provide the necessary examples to figure out how to do a lot of things I’d like to do. Here is a script that asks you where to save the current Safari Page, just like the “copy selection to…” does:

tell application "Safari"
   	if not (exists document 1) then error "No document is open."
   	set this_url to the URL of document 1
   	set this_source to the source of document 1
   	set this_title to the name of window 1
   	tell application "DEVONthink Pro"
   		set theDestination to display group selector "Destination" buttons {"Cancel", "OK"}
   		create record with {name:this_title, type:html, URL:this_url, source:this_source} in theDestination
   	end tell
   on error error_message number error_number
   	if error_number is not -128 then
   		display dialog error_message buttons {"OK"} default button 1
   		error number -128
   	end if
   end try
end tell

I’ve saved this as an “application” and placed it in the Dock, so I can easily click on it at any time.

I have to say it is a little slow - far slower than using the “Scrapbook” plugin for Firefox, but it works well enough, and then you can search the pages with DTP which is much faster than the Scrapbook search.

This script works great. Thanks! I saved it as an application as well. Great idea, and many thanks for sharing it!

I have a question about this script. I have a macro assigned to it and about 75% of the time it works seamlessly. But about 25% of the time I get a dialogue box asking if I want to quit or run the script. Can anyone explain why this happens on occasion? I notice nothing different about the circumstances, but something must be going on to generate this message.

Many thanks,


I wish I could help, but I have no idea. I haven’t been using this script myself. I’ve decided to stick with the “Scrapbook” plugin for Firefox, which seems to work much better for me.


In the release 1.0 of DT Pro there is a workflow called “Convert URLs to Webarchive” that does this for you. You’ll need DEVONagent however since Safari is currently crippled with its automation of the extraction of webarchives.

Also, check out the other Automator actions we’ve provided and the example workflows. Hopefully they will make your life easier with automating DT Pro. We’re always open to suggestions.

Pardon my ignorance, but what is the difference between html and web archive? Advantages/disadvantages?


An HTML document is a text file that’s the source code for viewing a Web page. While you are online, you may see images, movies, Flash animations, etc. But when you are offline, only the text of the page will be visible. Most HTML source code is not dynamic. That is, if You open the HTML document while you are online, you will not be able to view images if the Web page has been removed, or its images deleted.

A Web Archive is a proprietary Apple file type that stores the text and other content of a Web page, so that it will display images, etc. when you are offline. The file is not dynamic, i.e., it ‘freezes’ the content of the Web page as of the moment it was captured (although it is possible to update a Web archive to the current content of a Web page). So if a Web page is pulled off the Web, the Web Archive will still be fully functional.

Size: Because the Web Archive file contains graphics, etc in addition to text, it may require considerably more storage space than the corresponding HTML file.

Cross-platform compatibility: HTML files may be viewed on almost any computer, while Web Archive files can be viewed only on Macs running recent versions of OS X.

Offline usability: Web Archives have the advantage, as you view the Web page as it was meant to be viewed.

Hi Alexandria - I bet the macro you are assigning to the script includes the “control” key. And you’ve saved the script as an “application.” Am I right?

Script Applications (Applets) will put up the “start screen” at launch time if the control key is held down. What’s probably happening is that 75% of the time you release the control key before the applet finishes opening up.

You could either change the macro combination to not include the control key, or else save the script as a regular script file instead of an applet.


You are most correct!!! Many thanks for clearing that one up for me. I do indeed use the control key. I’ll change the macro and problem solved.

I lost hope of getting a response to this one. Many thanks again!


Also - If you’re using this script as an “Application” you will get much better performance by saving it as a plain compiled script.

You can use the free version of my FastScripts utility to assign up to 10 keyboard shortcuts for scripts. A major benefit of FastScripts is you can assign a keyboard shortcut that is only active while a particular app is active. So you could have a shortcut that only works in Safari, for instance.


Sounds great. I’ll give it a try. Many thanks!


How does one handle emails (Apple’s mail app) with attachments? I find that using the scripts, I have to first extract attachments (the problem is attachments that are not text) and deal with them first, otherwise sending such an email to DT sends everything as text - the attachment is embeded as text garbage. What’s the best workflow for dealing with this? Thanks.

Converting attachments via AppleScript is currently impossible, Mail can’t even return the text contents if a mail contains attachments. A future plugin not based on AppleScript will probably improve this.