Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
On 4/11/2012 4:44 PM, address@hidden wrote:
I have many files, 2.5 million, that I have to make available to Windows folks
They demand that the files have a extension added
Is there an efficient method of bulk renaming files
Richard
I know this is probably inappropriate, but my fave is in perl.
#!/usr/bin/perl
$op = shift;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}
This allows you to do things like
rename 's/$/.sav' *
or
find . -type f -print0 | xargs -0 rename 's/$/.sav/'
but you can also do cool things like
rename 'tr/A-Z/a-z' *
to cause all filenames to be lowercase
The corresponding big brother to this is replace_str
#! /usr/bin/perl -i.old
$from_text = shift ;
$to_text = shift ;
while( <> ) {
s/$from_text/$to_text/g ;
print ;
}
I promise never to inflict this on a bash list again. :-)
--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net