I got tired of copying a column of stuff from Excel, opening BBEdit, doing a find and replace to convert a bunch of lines into one block of comma-delimited text, selecting it all, copying again, and then finally pasting. I felt like I was that chump using an old fashioned blanket on the snuggie commercial.

So, I wrote this AppleScript.

clipboard newlines to commas and paste

Usage:

  1. Copy a column of stuff (from Excel, Numbers, anything really)
  2. Go to where you want to paste it as comma-delimited
  3. Invoke the script!

On my system, I run it with a keystroke trigger defined in Quicksilver. But you could use LaunchBar…or activate it from the scripts menu. By the way, if you want a system-wide scripts menu, here is a page that describes a nice way of activating a bunch of menu extras in OS X.

There are probably more elegant ways of doing this, but it has been working for me. If you find anything funky with it, let me know.

2 COMMENTS
Henry
July 24, 2009
ad

Hi mate,

The script is good. It has however a bug. It does not clean its stack memory when runs again. As it uses the first clipboard text again again, even the clipboard has new text. Would you submit a new version?

With thanks,
Henry

Henry
July 24, 2009
ad

I made a quick fix:

in the beginning of the script, before the clipboard being set:

local theBoard
set theBoard to ” ”
set theBoard to the clipboard

And at the very end, it is good to make a clean up, so I added the line:

do shell script “rm -f ~/Library/.temp_newlines ~/Library/.temp_commas”

Hope this helps a bit,
Henry

Post a comment