> -----Original Message-----
> From: Ashley Oviatt [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 28, 2005 12:07
> To: BYU Unix Users Group
> Subject: [uug] Change file names in batch
> 
> Hey, I have a directory that has the following filenames in it;
> 
> <snip>
> 
> etc...
> 
> I want to change them so they look like this (essentially, 
> take out the K):
> 
> DY1-1-MP.png  DK1-11-RP.png
> 
> etc...
> 
> Any way to do that in a batch?

Here's a script I keep in /usr/local/bin/plrename:

----------

#!/usr/local/bin/perl
# rename -- Larry's Filename Fixer

$op = shift or die "Usage: rename exper [files]\n";
chomp(@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
  $was = $_;
  eval $op;
  die $@ if $@;
  rename ($was, $_) unless $was eq $_;
}

----------

It can do batch renaming.  In your example, the command would be:

plrename "s/^DYK/DK/" DYK*png

--------------------
BYU Unix Users Group
http://uug.byu.edu/

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG.
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to