Category Archives: Scripts

A discussion of scripting of applications and tasks. Usually Applescript or Python but occasionally shell scripts.

Set Recipient & Sender in Mail

Surprisingly Applescript in Mail has a ton of weird limitations that haven’t been addressed in years. For instance the only way to script much of anything in an active compose window is via GUI Scripting. The following quick script sets the recipient and sender of your message.1

I use this with a philosophy mailing list I belong to. For some reason the “reply to” fields aren’t set right by the listserv software. But if I type the name Apple mail will sometimes grab an old email address from the server.2 

Continue reading

  1. Yes it’s a simple script. But I have readers who don’t do a lot of scripting who may find this helpful.
  2. I have the last 15 years of interesting messages from the listserv in my archives. Apple mail sometimes will autocomplete based upon the “from” of one of these old messages regardless of what I have in the Contacts app.

Hashbanging Swift

Hashbanging Swift. Using Swift at the command line. I had enough issues trying to replace Python with Swift that I went back to Python.

Related Posts

  • 55
    I’d mentioned in passing in one of my Swift posts about using it as a scripting language. Someone on Twitter asked me if I’d convert from using Python to Swift for my scripts. It’s an excellent question that I really can’t answer fully at this stage. The language is still very beta. Most of the…
    Tags: swift, python
  • 45
    Swift’s command line tools have changed somewhat. (HT: SwiftDevs)
    Tags: swift, command
  • 43
    Calling Swift from C.
    Tags: swift

Using Swift as a Scripting Language

I’d mentioned in passing in one of my Swift posts about using it as a scripting language. Someone on Twitter asked me if I’d convert from using Python to Swift for my scripts. It’s an excellent question that I really can’t answer fully at this stage. The language is still very beta. Most of the bugs I’ve submitted appeared to have been fixed but I’m somewhat loath to get too far into Swift until it gets a little more mature. Say at least beta 3 or 4. However here’s my thinking although this is somewhat preliminary. I’ve just not tried to use Swift as a practical scripting language.

Continue reading

Related Posts

  • 55
    Hashbanging Swift. Using Swift at the command line. I had enough issues trying to replace Python with Swift that I went back to Python.
    Tags: swift, python
  • 49
    Better error handling in Swift. (HT: Brent Simmons indirectly) Very cool. Even better than returning tuples as in Python.
    Tags: swift, python
  • 46
    Over at the old blog many of my posts were focused around automation and especially scripting. My scripting language of choice was Python + Appscript. Appscript is no longer supported (although I keep using it) I have switched to using a few more Applescript scripts, but I really hate that language even though I love…
    Tags: scripts, scripting, code, swift, python
  • 45
    OK this one is a bit silly. However I was curious if I could use ApplescriptObjC with Swift. Why? Mainly giggles and also to see if there was an easy way to bridge certain stuff from Applescript but do my actual scripting in Swift. The trick to calling ApplescriptObjC objects from Cocoa is to create…
    Tags: swift, scripting
  • 44
    Changes to Swift in Beta 6. When I played around with Swift last week I was shocked how much of my code from June needed tweaking. I’m definitely going to wait until Swift settles down a little before going again.
    Tags: swift, code

My Scripts

Over at the old blog many of my posts were focused around automation and especially scripting. My scripting language of choice was Python + Appscript. Appscript is no longer supported (although I keep using it) I have switched to using a few more Applescript scripts, but I really hate that language even though I love the idea of Apple Events. I find it sad that fewer and fewer applications really are support scripting via Apple Events. I’m hoping the announcement of Javascript for Applescripting will improve this. I know I’m not alone in disliking the Applescript language while loving a lot of the technology behind it.1

Most of my scripts haven’t been updated in a while, but I try and keep the main ones on GitHub for others to use. As I make significant updates I’ll update the GitHub versions. So if you are interested in my scripts, please check out that repository. Now that Swift is becoming a bit more mature I may try doing some scripts with it in the future.

Continue reading

  1. My favorite joke along these lines is that Perl is a write only language because anyone can writes something in it but it’s nearly impossible to read someone else’s code. (This was in the days of Perl 3) Applescript is a read only language because it’s trivial to read a program and figure out what it does but nearly impossible to easily write a script in it.

Related Posts

  • 46
    I’d mentioned in passing in one of my Swift posts about using it as a scripting language. Someone on Twitter asked me if I’d convert from using Python to Swift for my scripts. It’s an excellent question that I really can’t answer fully at this stage. The language is still very beta. Most of the…
    Tags: swift, python, scripts, scripting, code