7/23 Long bit truncated down to:
but this is what i wanted to do:
foreach f (*.gif)
mv $f `echo $f | sed 's/\(.*\)\.gif/\1th.gif/'`
end
it seems like it's better done at the command line. I didn't think
you can do that in as few bytes (and processes) in perl.
\_ If you want to do it once, period, for the rest or eternity,
fine, do that. But the perl is:
foreach $f (<*.gif>) {
$f =~ s/\.gif$//;
rename("$f.gif", "${f}th.gif");
}
Process count: Shell: 4 Perl: 1
Process count: Shell: 4 per file renamed Perl: 1
Byte count: Shell: 90 Perl: 139
49 more bytes, but runs much, much faster (really, try it on
Byte count: Shell: 70 Perl: 75
\_ isn't the carat supposed to be a dollar-sign? -- idiot
\_ 68 bytes but uglier:
5 more bytes, but runs much, much faster (really, try it on
even 50 files) --dbushong
\_ 66 bytes but uglier:
foreach (<*.gif>) {
s/\.gif$//;
rename("$_.gif", "${_}th.gif");
}
\_ 62 bytes:
\_ 57 bytes:
$g=".gif";foreach(<*$g>){s/$g$//;rename($_$g,${_}th$g);}
\_ are you sure you can do $_$g ?
\_ with the extra added bonus of globbing via <> ick ick but that's
a stylistic issue |