Today I had the need to add a bunch of named text files to a folder in the Finder on my Mac. I found it a major pain that I had to open up BBEdit, make a new document, then save it to where I wanted it, and then manually copy & rename the files back in the Finder. A lot of effort to get 7 or 8 empty files with different names. [Read more...]
AppleScript to Toggle the Desktop
Here’s an AppleScript I use to quickly toggle desktop visibility for taking screenshots and recording screencasts. Thought I’d share it with the world.
Copy and paste the code below into AppleScript Editor, or your editor of choice, compile and save.
As always, scripts like this work best using FastScripts from Red Sweater Software.
on run
tell application "System Events"
set _activeApp to name of the first process whose frontmost is true
end tell
try
set _theVar to ((do shell script "defaults read com.apple.finder CreateDesktop") as integer) as boolean
on error -- if the default value doesn't already exist, create it...
do shell script "defaults write com.apple.finder CreateDesktop 1"
set _theVar to ((do shell script "defaults read com.apple.finder CreateDesktop") as integer) as boolean
end try
do shell script "defaults write com.apple.finder CreateDesktop " & (((not _theVar) as integer) as string)
tell application "Finder" to quit
delay 1
tell application "Finder" to launch
tell application _activeApp to activate
end run
Note: This single script turns off the desktop if it’s on, and turns it on if it’s off – just to clear up the question should it need to be asked.
AppleScriptTweet Updated for Use With “Twurl”
Thanks to Karl and Matt letting me know about Twurl, my AppleScriptTweet script now works with OAuth authentication. Here’s how to get it working for yourself…
1. Download the updated script: http://jimmitchell.org/files/AppleScriptTweet.zip
2. Use the Terminal.app (/Applications/Utilities/) to install the “twurl” rubygem – a Twitter-friendly version of curl:
$ sudo gem install twurl
3. Create a new application at dev.twitter.com to obtain an API key. After logging into Twitter with the account you want to use AppleScriptTweet with, go to http://dev.twitter.com/apps/new, and fill out the form:
- Application Name: Anything (but must be unique, may take an attempt or two)
- Description: AppleScriptTweet – tweet from AppleScript (or add your own description)
- Application Website: http://jimmitchell.org/projects/applescripttweet/
- Organization: http://jimmitchell.org/
- Application Type: Client
- Default Access type: Read & Write
4. Accept the Terms & Conditions, and copy down the “consumer key” and “consumer secret” that appear on the next page.
5. Go to the twurl github webpage and follow the instructions for authenticating in Terminal: http://github.com/marcel/twurl/
6. Change the property values in the AppleScriptTweet script with AppleScript Editor:
- property theAccount : “YourTwitterAccount” — this is the Twitter account you created the app for in step #2
- property theApp : “YourApplicationName” — this is the application name you used in step #2
Save the script and that’s it. You should be good to go now.
Note: I cannot (and won’t) answer support questions regarding the use of twurl. It’s not my code, so I can’t do anything if it breaks your system. The one thing I can shed some light on is that the “twurl authenticate…” command in the Terminal should be entered all on one line.
Any questions about AppleScriptTweet should be posted in the comments here. Enjoy!
New AppleScript to Post to Twitter

I’ve hacked together a quick little AppleScript that will let you post quick one-off tweets to Twitter without the hassle of dealing with a full-on client.
I originally created it to fire off quick to-do’s to Remember the Milk. Combined with FastScripts from Red Sweater Software, it takes me 2 seconds to get that to-do reminder out of the way and back to work. It also keeps me from browsing through my Twitter feed, which my ADD nature tends to want to do.
If it sounds like something you could use, go check it out. The code is totally open source, so add to it as you have need. If you come up with something cool, let me know.




Recent Comments