Copy file to Dropbox and email link
A while back I posted a script that copied a file to a users MobilMe Public folder and created an email link to that file. With the imminent demise of MobileMe a couple of people have asked me for a script that does the same but uses Dropbox.
This script shows how to copy a file to your Dropbox Public folder and then email a link to it.
Script to email Chemical Structures
A reader commented that they often emailed ChemBioDraw .cdx structures to colleagues who it turned out did not have a copy of ChemBioDraw to view them, whilst it is possible to convert the cdx file to other formats using OpenBabel they usually just ended up exchanging an image. They asked if there was a better solution and this is an ideal task for Applescript. This script assumes the structure you want to email is open in ChemBioDraw, it will create an email using Apple Mail containing the structure as a SMILES string, and embed the .cdx file together with an image in PNG format.
KosmicTask
KosmicTask is an integrated scripting environment for Mac OS X. Whilst Mac OS X supports a number of scripting technologies either via it’s UNIX roots (Shell scripting , Perl etc.) or via Cocoa Framework Scripting using Apple’s scripting bridge (Applescript, Ruby, Python etc.) you can end up using a different script editor for each scripting language. KosmicTask allows you to script in a wide variety of languages from within a single editor. KosmicTask uses a plugin architecture that allows it to support a range of scripting languages, details of the languages supported by KosmicTask are shown below:-
- AppleScript
- AppleScript Cocoa - AppleScriptObjC
- Bash Shell
- C Shell
- C and C++
- F-Script Cocoa
- Java
- JavaScript
- JavaScript Cocoa - JSCocoa
- Korn Shell
- Lua
- Lua Cocoa
- PHP
- Perl
- Python
- Python Cocoa - PyObjC
- Ruby
- Ruby Cocoa
- Tcl
- Tenex C Shell
- Z Shell
KosmicTask also supports another very capable means of achieving automation - appscript. Appscript is supported by both Ruby and Python an alternative to the ScriptingBridge.
It also allows sharing of scripts with other KosmicTask users via the local shared network.

I’ve also added it to the list of Applescript Resources.
Applescript to report installed and enabled extensions
When Apple released Safari version 5 one of the most important new features was the support for extensions. Extensions are a great way to add features to Safari to personalise web browsing, they enable the addition of features that you find useful. There is a listing of Extensions that might be useful for chemists and judging by the weblogs these are of significant interest. If you are working with them however it is a bit of a pain to check which are installed and which are enabled. This applescript is a very neat way of getting a report, it also serves as a demonstration of how to link to shell scripts, in particular using the unix command cat, a standard Unix utility that concatenates and lists files, to generate the report.
ASObjC Runner released.
ASObjC Runner is an invaluable scriptable faceless background helper application. It has a dictionary with a range of commands focused on the areas where vanilla AppleScript comes up short. It adds the ability to use the power of Cocoa frameworks within Applescript.
You use it like a scripting addition, except you address the commands to the application. It provides better string handling (e.g. change case, encoding URL’s, regular expression, formatting dates), list sorting and filtering, improved file handling and progress dialog boxes.
I’ve added to the page of Applescript Resources
Scripting the Chemical Identifier Resolver Updated
I was reminded that whilst scripting menu items was the traditional way of controlling ChemDraw the more recent releases allow control by scripting commands. This is a major advance since menus can change or be translated into other languages. I’ve thus updated the script.
I was asked if it would be possible to do the same thing for other drawing packages such as MarvinSketch?
The answer is yes but because MarvinSketch does not have applescript support we have to do it slightly differently. Rather than using scripting commands we script system events to evoke the “Paste” command.
Full details of the script are here
Scripting the Chemical Identifier Resolver
The name to structure feature in ChemBioDraw is very useful but is pretty much limited to systematic names and certainly does not support other chemical identifiers like CAS Numbers. There are a number of online services that do support these sort of functions but you end up having to cut and paste from different web sites. This is where the Chemical Identifier Resolver script comes into play.
AppleScriptObjC Explored
The 'AppleScriptObjC Explored' Addenda and Errata page has been updated to cover a change made in Xcode since version 4.0 came out. <http://www.macosxautomation.com/applescript/apps/errata.html>
AppleScriptObjC Explorer v2.2 is now available. It's a free update to existing users, and incorporates all the changes in the last beta version, plus built-in updating.
Myriad Helpers 1.0.2 is now available. It's a minor update, offering a new method fordTrig: to give access to trigonometry functions. <http:www.macosxautomation.com/applescript/apps/helpers.html>
AppleScriptObjC Explored Third edition
Over the years I’ve migrated from Applescript Studio applications to AppleScriptObjC using Xcode 3 and last week I made the transition to Mac OSX 10.7.x and Xcode 4. With each transition there has been a very steep learning curve and to be honest the documentation provided by Apple has been woefully inadequate. Thankfully Shane Stanley has stepped up to the plate and provided a definitive guide for this people who want to build applications using applescript. AppleScriptObjC Explored is the definitive guide to building AppleScript Objective-C applications. It guides you step-by-step through the process of integrating the power of Cocoa into your AppleScript applets and applications, demonstrating each concept and technique in fully editable and annotated example projects.
The latest edition also includes a detailed navigation of Xcode 4, for those of us who had just learnt our way around Xcode 3 the changes made in the new version are significant and the section explaining where everything is and what they are for is invaluable, in fact it is probably worth reading this section before you start trying to write your first application.
Once you have a basic understanding of Xcode adding an interface to your script becomes largely point and click.
There is also a very useful section on trouble-shooting, and explanation of “gotchas” that will crop up occasionally.
The book comes with a collection of over 20 ready built Xcode tutorials/projects that demonstrate key implementations but that can also act as starting points for your own projects.
Whilst I keep a list of applescript resources, I suspect that AppleScriptObjC Explored is probably the most useful.
Scripting the Organic Chemistry Reference Resolver
The Organic Chemistry Reference Resolver is an invaluable web service that takes as input a text reference to a published article in a variety of formats and then finds and displays the corresponding publication.
The real beauty of a web service is that it can be accessed via a variety of means, including an applescript. This applescript uses as input either text that has been copied to the clipboard or the text the user has typed into a text box, it submits the request to the web service and displays the result in the web browser.
An alternative to the Delete Restore folder applescript
Matt over at MacOSX Tips has sent me an alternative script, in this rather than deleting the restore file it is simply enabled or disabled. This script demonstrates the implementation for Safari.
Delete Restore folders for selected applications
One of the new features in Lion is the ability of applications to resume activity at the point an application was quit. This means that when you reopen an application it will open and display all the documents you were editing in the state when you quit the application. This is obviously very useful but there are times when you may not want confidential documents automatically opened and displayed when you open an application.
This Applescript allows you to delete the restore folder for specified applications.
There are more applescripts here.
Update to AppleScriptObjC Explorer
Version 1.1.0 is now available. It includes several localizations, more frameworks, and the ability to check for and install updates. See http://www.macosxautomation.com/applescript/apps/runner.html for details.