http://www.perlmonks.org?node_id=751666


in reply to Re^3: Renaming files in dir
in thread Renaming files in dir

Thanks, there is still a problem, because this code does not rename those files. What should I do?
#!/bin/perl #usage: #C:\Perl>perl Print_dir_sizes.pl "C:/Perl/" use warnings; use strict; use File::Copy; my $path = $ARGV[0]; die "You must supply a full directory path" unless (-e $path && -d $pa +th); my @dirs; opendir(DIR, $path) || die "can't opendir $path: $!"; my @fileet = grep { -f "$path/$_" } readdir(DIR); closedir(DIR); foreach my $file (@fileet) { my $newfile = $file; $newfile =~ s/ä/ä/g; $newfile =~ s/ö/ö/g; move("$file", "$path/$newfile"); }

Replies are listed 'Best First'.
Re^5: Renaming files in dir
by larus (Acolyte) on Mar 19, 2009 at 10:56 UTC
    Oh yes, I found it:
    foreach my $file (@fileet) { my $newfile = $file; $newfile =~ s/ä/ä/g; $newfile =~ s/ö/ö/g; move("$path/$file", "$path/$newfile"); }
    The error was here
    move("$path/$file", "$path/$newfile");