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:
\d+\.\.txt
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
Re:
Aristotle on 2005-01-13T05:34:36
Check out my
rename script.
rename
da on 2005-01-15T04:32:45
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 ]