in reply to Re3: How can I opendir, replace all files containing a space with .?
in thread How can I opendir, replace all files containing a space with .?
print "$newfile\n"; presents the correct name but no changes occur in the directory DIR. That's why I tried implementing the open function. Perhaps rename isn't working properly?opendir(DIR, "$dir") || die "cant open $dir $!\n"; foreach my $filename (readdir(DIR)) { if ($filename =~ / /) { my $newfile = $filename; $newfile =~ s/ +/./g; rename($filename, $newfile) unless $filename eq $newfile; } } closedir(DIR);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re5: How can I opendir, replace all files containing a space with .?
by Hofmator (Curate) on Aug 15, 2001 at 20:50 UTC | |
by nkpgmartin (Sexton) on Aug 15, 2001 at 21:04 UTC |