I’ve dropped Larry's filename fixer into ~/bin for as long as I can remember. It’s from the Perl Cookbook and that Larry.
Larry's filename fixer
~/bin
#!/usr/bin/perl -w # rename - Larry's filename fixer $op = shift or die "Usage: rename expr [files]\n"; chomp(@ARGV = <STDIN>) unless @ARGV; for (@ARGV) { $was = $_; eval $op; die $@ if $@; rename($was,$_) unless $was eq $_; }
It lets you apply perlre to file renaming operations:
perlre
$ rename 's/foo-(\d+)/$1-bar/' *.baz
More examples and notes here.
Unfortunately my ~/bin also contains cvs-wtf-arg:
cvs-wtf-arg
#!/bin/sh cvs up 2>/dev/null | grep "^\?"
because I work on one project that still uses CVS. If you know why I need this then I apologise.
I’ve dropped
Larry's filename fixer
into~/bin
for as long as I can remember. It’s from the Perl Cookbook and that Larry.It lets you apply
perlre
to file renaming operations:More examples and notes here.
Unfortunately my
~/bin
also containscvs-wtf-arg
:because I work on one project that still uses CVS. If you know why I need this then I apologise.