New tool: sednames

2008-06-20 21:21:10 -08:00

What if you could use sed to rename files?

Well, now you can.

sednames is a utility that lets you specify a program for sed on the command-line, which it then uses to rename the files that you also specify on the command-line.

The twist is that, unlike other batch-renamers, sednames also supports your VCS. For the most common cases (svn, hg, bzr, and git), there’s a –vcs option:

% sednames -e 's/Replace/Mix/' --vcs=hg *

This command-line will use Mercurial (hg mv) to rename every file by replacing “Replace” with “Mix”. Of course, if a name doesn’t contain “Replace”, then that name will be unchanged and sednames is smart enough to not try to rename that file.

Not only that, but just in case you’re using some oddball VCS (or you want to copy instead of rename, or something), sednames supports using any program to rename your files, as long as it accepts both the before and after names in its arguments. The –help output is more specific, but to put it simply, it works similarly to find‘s -exec option.

You can download the current revision directly, or use the Mercurial repository to follow or contribute to its development.

8 Responses to “New tool: sednames”

  1. Matthew Schinckel Says:

    I don’t know why, but this post keeps reappearing in my feed. Over and over again.

    I think there are minor edits being made to it, but I don’t know that you are necessarily intending for it to repeatedly appear in the feed.

  2. Peter Hosey Says:

    Matthew Schinckel: I haven’t edited it in a week or so. Try unsubscribing and resubscribing, or clearing out your feed reader’s folder in Library/Caches.

  3. Matthew Schinckel Says:

    Strange – I’ve done that (a couple of times), and this post, as well as only two others, (WWDC Survival Guide, and the Keyboard one) keep reappearing the newly updated feeds list.

    No biggie. Unless it is happening for other people.

  4. Eric Says:

    “No biggie. Unless it is happening for other people.”

    It is. Netnewswire shows the quotation marks changing each time.

  5. Chris Says:

    That actually happens to me a lot with this RSS feed (and no others, out of about 140) for some reason. I’m also using NNW.

    Hmm, the quotes are using raw 8-bit characters and that may (obviously) be causing problems if the encoding is not set correctly. They show up correctly in Safari, but as ??? in NNW at the moment. I can’t imagine why that should cause the feed to be marked unread, though.

    But I’m not writing solely to kvetch, no! I will share a marginally relevant tidbit. The Unix Haters Handbook has a great quote from Jamie Zawinski on sed:

    “Some people, when confronted with a problem, think ‘I know, I’ll use sed.’ Now they have two problems.”

  6. Peter Hosey Says:

    Hmm, the quotes are using raw 8-bit characters and that may (obviously) be causing problems if the encoding is not set correctly.

    The Atom feed says:

    Content-Type: application/atom+xml; charset=UTF-8

    The RSS feed serves up a redirection (Moved Permanently) whose HTML depiction says:

    Content-Type: text/html; charset=”UTF-8″

    The destination of that redirection is FeedBurner, which says:

    Content-Type: application/atom+xml;charset=utf-8

    So, make sure you’re subscribed directly to the FeedBurner URL, and it should definitely work.

  7. Chris Says:

    I’m subscribed directly to feedburner. Here’s what I see (via curl). Note last-modified date.

    I’ll switch to Atom, in any case.

    curl -L –verbose -O
    * About to connect() to port 80 (#0)
    * Trying… connected
    * Connected to ( port 80 (#0)
    > GET /domainofthebored HTTP/1.1
    > User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3
    > Host:
    > Accept: */*
    < HTTP/1.0 200 OK
    < Date: Wed, 10 Sep 2008 13:45:41 GMT
    < Server: Apache
    < X-FB-Host: app86
    < Last-Modified: Wed, 10 Sep 2008 13:41:54 GMT
    < ETag: eLBbRlgLEs6aXC/Csb8GzK9fINY
    < Connection: close
    < Content-Type: text/xml;charset=utf-8

  8. Peter Hosey Says:

    The Last-Modified date is probably because FeedBurner shows the number of comments on the feed. This post is in the last ten, so it’s still in the feed (I forgot what I set the number to, but it’s at least ten). So, every comment on this post bumps the feed.

    Getting back to the encoding problem: I just tried the FeedBurner feed in NetNewsWire 3.1 and it works fine. The quote marks in this post show up as quote marks.

Leave a Reply

Do not delete the second sentence.