"Brian E. Lavender" <br...@brie.com> writes:

> Shell command that does the following.
>
> rename "s/^/foo/" *.txt

I think I posted it a long time ago.  It was written before the command
line rename program existed, so there wasn't a conflict.

#!/usr/bin/perl

($op = shift) || die "Usage: rename expr [files]]\n";

if(!@ARGV)
  {
  @ARGV = <STDIN>;
  chop(@ARGV);
  }

for (@ARGV)
  {
  $was = $_;
  eval $op;
  die $@ if $@;

  if ($was ne $_)
    {
    print "rename($was,$_)\n";
    rename($was,$_);
    }
  }

exit;

-- 
Wes Hardaker                                     
My Pictures:       http://capturedonearth.com/
My Thoughts:       http://pontifications.hardakers.net/
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech

Reply via email to