Link dump

Reading: Felicia Day’s autobiography, You’re Never Weird on the Internet (Almost). In fact, I’m listening to it. First crack at using my library’s audio book reservation. It’s a fantastic book; very relatable and touching. A story of an interaction with a fan may have made my bus ride home uncomfortably dusty.

Listening to: Chipzel radio on Google Play Music. Making my peace with the upcoming death of Songza.

Playing: Toca Builders on iPhone. Yes, it’s for kids. But it’s really great. On my Mac, I’m playing Last Horizon.

Using BBEdit’s shell worksheet to rename files

BBedit’s shell worksheet can be a really handy tool for batch renaming files. I was inspired to give it a shot after seeing a script that handed off a directory listing for editing. Here’s a really trivial example. Let’s say I have a directory containing the following files (and I’ve cd‘d to it in the worksheet):


And let’s say those files are actually Markdown, so I want to change the extension to .md.

First, type ls and execute it with Control-Return to get the listing of those files in your worksheet window. The result looks like the example above.

Next, highlight the listing, and bring up the “Find” dialogue. Make sure that “Grep” and “Selected text only” are selected.

Enter the pattern (.*?)(\.txt), meaning a lazy search of any characters up to a literal .txt, broken into two tokens. The first token is the file name, the second token is the extension. You want to replace that with mv \1\2 \;. The result will look like this:

mv foo1.txt;
mv foo2.txt;
mv foo3.txt;

Select those lines and execute them using Control-Return. If you do another ls, you’ll see your files have been renamed.

This example is really simple, just to get you thinking about the kind of file renaming you can do. Remember that a shell worksheet in BBEdit is a regular editing window. Any snippets, scripts, or text factory you have set up are available to you.