[conspire] How automatically replace control (newline) character with space in file & directory names

Hereon hereon1 at fastmail.us
Sun Dec 4 15:10:19 PST 2005


Bill - Thank you.  I'll be studying this later today.
To cabal list readers - sorry for the duplicate posts - reasons, no
excuses. :( :)

On Sun, 4 Dec 2005 11:11:38 -0800, "Bill Ward" <bill at wards.net> said:
> Oops, I noticed a typo: #! should be $! in the 3rd line.
> 
> On 12/4/05, Bill Ward <bill at wards.net> wrote:
> > #!/usr/bin/perl -w
> > use strict;
> > opendir DOT, "." or die "Can't read directory: #!\n";
> > foreach my $file (readdir DOT) {
> >     my $newfile = $file;
> >     $newfile =~ s/\n/ /g;
> >     next if $newfile eq $file;  # skip files that lack \n
> >     if (-e $newfile) {
> >          warn "Can't rename $file because $newfile already exists\n";
> >     }
> >     else {
> >         rename $file, $newfile or die "Error renaming $file: $!\n";
> >     }
> > }
-- 
  Hereon
  hereon1 at fastmail.us

-- 
http://www.fastmail.fm - The professional email service





More information about the conspire mailing list