...

Menu Close

BBEdit to MarsEdit (AppleScript)

You can never own too many text editors. Okay, I can never own too many text editors. I recently splurged on BBEdit, the venerable HTML and text editor for the Mac. There’s something pleasurable about tweaking BBEdit to use it as a blogging tool. One such tool I hacked together is an AppleScript to send a post from BBEdit to MarsEdit for final publishing. Here’s how you do it.

Paste the following text into the Script Editor app on your Mac (warning: I’m no coder, and did this through trial and error based on other scripts, so this script probably contains some completely unnecessary code):

on run
	tell application "BBEdit" to set theFile to file of document 1
	
	
	set appleScriptPath to theFile as text
	set currentURL to POSIX path of appleScriptPath
	set currentURL to ("file://" & currentURL)
	
	tell application "MarsEdit"
		activate
		make new document
		tell document 1
			set body to theFile
		end tell
		activate
	end tell
end run

Compile then save the AppleScript. For the final step, you need to move this AppleScript to the BBEdit scripts folder. Get there by clicking on the Scripts icon near the far right of the BBEdit menu, and choosing “Open Scripts Folder.”

BBEdit menu item - Scripts folder

Once the AppleScript is in place, it will appear at the bottom of the dropdown when you click on the Scripts icon. Selecting it will take the text in BBEdit, and open it in a new MarsEdit document. I wrote the initial draft of this post in BBEdit, before using the AppleScript to send it to MarsEdit for final edits, adding of the image, assigning tags and categories, and sending off to WordPress.