Allison,

Try this script.  I found it out on the net.  My need was to rename a set of files but 
I don't see any reason that this couldn't rename a single file.

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

($regexp = shift @ARGV) || die "Usage:  rename perlexpr [filenames]\n";

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


foreach $_ (@ARGV) {
   $old_name = $_;
   eval $regexp;
   die $@ if $@;
   rename($old_name, $_) unless $old_name eq $_;
}

exit(0);

Craig A. Sharp
Unix Systems Administrator
DNS Administrator
Roush Industries
Office: 734-466-6286
Cell: 734-231-6769
Fax: 734-466-6939
[EMAIL PROTECTED]
====================================================
I have not lost my mind, it's backed up on tape somewhere!
====================================================

>>> "Allison Ogle" <[EMAIL PROTECTED]> 04/10/02 10:05AM >>>
Hi,

I am trying to open a file which has no file extension.  (For example ABC ).
What I want to do is rename the file with a file extension.  (For example
ABC.dat).  Does anyone know how to do this?
Thanks,

Allison


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to