in reply to Renaming files
What you do in your code is getting names of files froma directory and then changing the in-memory strings, which has no effect on the actual file. Try this (untested):
--my $dir = '.'; require File::Spec; opendir my $dh,$dir or die "$dir - $!"; while(defined(my $f = readdir($dh))){ local $_ = File::Spec->catpath(undef,$dir,$f); next unless -f; $f =~ tr/ \t/_/s; my $np = File::Spec->catpath(undef,$dir,$f); rename $_ => $np or warn "rename '$_' to '$np': $!"; } closedir $dh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Renaming files
by Anonymous Monk on Oct 25, 2002 at 17:34 UTC | |
by fruiture (Curate) on Oct 25, 2002 at 17:50 UTC | |
|
Re: Re: Renaming files
by Anonymous Monk on Oct 25, 2002 at 17:34 UTC |