CLI ABFR
Posted March 21st, 2006 @ 01:44pm by Erik J. Barzeski
Pardon me for thinking so, but $19.95 for A Better Finder Rename (or even $9.95 for the upgrade and $24.95 for the "forever" license) is a bit more than I'm willing to pay for a tool I need to use, at most, about once a month.
But isn't there some sort of CLI tool that can do this? Obviously I can pipe some commands through some awkward sed chain or something, but isn't there some "renamer" tool that can do things like find and replace " " with "_" in filenames and lower-case any upper-case letters? Simple things like that?
And if there isn't one already, would someone be interested in working on one with me?
Posted 21 Mar 2006 at 2:17pm #
Have you tried Automator's "Rename Finder Items" action?
Posted 21 Mar 2006 at 2:26pm #
Brooke, I have. It's not a CLI app, of course, but it's a good substitute for ABFR. I'm still hoping to find (or build) a CLI version.
Posted 21 Mar 2006 at 2:30pm #
I use Renamer4Mac. It's a GUI app, but it's free and has (among other options) regex support.
Posted 21 Mar 2006 at 3:03pm #
I typically use the Finder scripts that are included with Mac OS X, accessible via the Scripts menu, but that's not a command-line solution either.
Posted 21 Mar 2006 at 3:05pm #
A lot of linux distributions include a perl script called "rename" which lets you specify perl code for modifying names. (For example, to rename *.foo to end in .bar, you could run "rename 's/foo$/bar/' *.foo")
I found a copy of the source here
run "pod2man rename > rename.1" to generate the man page (then stick it wherever you keep man pages for stuff you've installed) .. if you just want to view it, you can use "pod2man rename | nroff -man | less" (or just "pod2text rename" if you don't care about underlines, bold, etc.)
Posted 21 Mar 2006 at 4:31pm #
File Buddy is pretty nice for this type thing (although it's much much more than a renamer.)
Posted 21 Mar 2006 at 4:52pm #
The perl util is nice. You can also use some simple shell scripting (no need for sed/awk):
For instance, say you want to UPPER->lower files:
$ mkdir test
$ cd test
$ for i in 1 2 3 4; do touch ABCD$i; done
$ ls
ABCD1 ABCD2 ABCD3 ABCD4
$ for i in `ls`; do j=`echo $i | tr [A-Z] [a-z]`; mv $i $j; done
$ ls
abcd1 abcd2 abcd3 abcd4
Of course you'll be creating 2 new processes for every file...
Posted 21 Mar 2006 at 6:40pm #
find . -type f -name \*.whatever -print0 | xargs -0 rename -s/FROM_PATTERN/TO_PATTERN/g
works under most shells.
Posted 21 Mar 2006 at 8:39pm #
To go with all of the other posts that don't offer a command line solution, I recommend R-Name as an excellent replacement for ABFR. With the AppleScript I have, you can even make a selection and press Command-Shift-R to start the process.
Posted 21 Mar 2006 at 11:56pm #
Try R-Name3. It's free.