[ale] Need a "find and rename" script

Jonathan Feldman Jonathan at wpo.co.chatham.ga.us
Thu Aug 24 09:08:01 EDT 2000


>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