A Couple of Quick AppleScripts

Here’s a couple of quick AppleScripts I use all the time with Red Sweater Software’s excellent FastScripts to add some key shortcuts.

Clipboard to Single Line
This script takes the contents of the clipboard and converts the text to a single line. This is great for copying a street address from a webpage or document and then pasting the result into Google Maps or whatever.

Here’s the source:

	set addressString to the clipboard as string
	set text item delimiters to return
	set textItems to text items of addressString
	set addressString to ""
	repeat with i in textItems
		set addressString to addressString & i & " "
	end repeat
	set the clipboard to addressString

Clipboard to Tiny URL
This script calls tinyurl.com using curl, and turns a long URL on your clipboard into a short one. The contents of the clipboard are replaced with the short URL.

Here’s the source:

	set longURL to the clipboard
	set cmd to "curl http://tinyurl.com/api-create.php?url=" & longURL
	set shortURL to do shell script cmd
	set the clipboard to shortURL as text
	beep

Download ClipboardScripts.zip (4kb)

Leave a Reply