Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Tuesday January 11, 2005
08:31 PM

brian's a dumbass, 2005

[ #22668 ]

It's not even two weeks into the new year and I'm already a big fat dumbass.

I have a bunch of files named with this pattern:


Huh? Where did those double dots come from?

my $file = File::Spec->catdir( $folder,
    join ".", $index, '.txt'

Well, which is it going to be? I can either join() on a dot or have the dot in the extension.

No matter: it was easy to fix (code and problem).

perl -e 'for(@ARGV){($s=$_)=~s/\.\././;rename($_, $s)}' *..txt

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Check out my rename [] script.
  • Similarly, debian's perl package comes with /usr/bin/rename, based on Larry Wall's example from the perl source. I believe it's written up in the Cookbook as well. great stuff, it's saved me many little bits of time here and there.
    rename [ -v ] perlexpr [ files ]

    -DA []