On Sun, Jan 23, 2000 at 10:54:42PM -0500, Arcady Genkin wrote: > What would be the easiest way to rename a bunch of files > > foo-[0-9]-bar-[0-9][0-9].txt > > into > > blah-[0-9]-[0-9][0-9].txt
Try the attached Perl script (just put it in a directory that's in your path and make it executable). To do what you want you just give the following command in your shell: $ rename 's{foo-(.)-bar-(..)\.txt}{blah-\1-\2.txt}' *.txt -- Maciej Kalisiak | <[EMAIL PROTECTED]> | http://www.dgp.toronto.edu/~mac [McQ] PGP->finger|www; (0x39AC36F5) 9F BB 9E 11 F0 1E 5D 20 0B 31 3D 37 47 D0 67 C7 GE/CS d- s++:+ a- C++(+++) ULAI++ P+++ L+++ E+++ W++ N- o? K? !w--- O- M- V-- PS PE+ Y+ PGP+ t+ 5 !X-- R+ tv-- b+>++++ DI+ G+ e>+++>++++(*) h--- r+++ y?
#!/usr/bin/perl # Usage: rename perlexpr [files] ($op = shift) || die "Usage: rename perlexpr [filenames]\n"; if ([EMAIL PROTECTED]) { @ARGV = <STDIN>; chop(@ARGV); } for (@ARGV) { $was = $_; eval $op; die $@ if $@; rename($was,$_) unless $was eq $_; }