[ale] Need a "find and rename" script

Armsby John-G16665 John.Armsby at motorola.com
Thu Aug 24 11:25:46 EDT 2000


It Works!!!!!!!!!!!!

Thanks,

John


-----Original Message-----
From: Jonathan Feldman [mailto:Jonathan at wpo.co.chatham.ga.us]
To: ale at ale.org
Sent: Thursday, August 24, 2000 9:08 AM
To: ale at ale.org; John.Armsby
Subject: Re: [ale] Need a "find and rename" script


>From the Camel book.  I've done this, it works.

#!/usr/bin/perl
# Usage : rename perl expr[files]

($op = shift) || die "Usage: rename perlexpr [filenames]\n";
if (!@ARGV) {
  @ARGV = <STDIN>;
  chop (@ARGV);
}

for (@ARGV) {
  $was = $_;
  eval $op;
  die $@ if $@;
  rename ($was,$_) unless $was eq $_;
}


Example:

find . -print | rename 's/\.tif$/.g01/'

Hope that works for you!  (Most common problems might include needing to do
a chmod of the script to be executable; or the path of perl being somewhere
other than /usr/bin).

Cheers,

--Jonathan
"Teach Yourself Network Troubleshooting"
"Network+ Exam Guide"
http://feldman.org

>>> Armsby John-G16665 <John.Armsby at motorola.com> 08/24 7:53 AM >>>
I have a large number of .tif files burried in a directory tree which need
to be renamed to .g01.  I am shell script challenged.  Does anyone have a
simple script to "find" the files which have a .tif extension and rename
them to .g01 while leaving the other file types along?

Thanks,

John 

 
!
!
 

--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list