Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^2: Renaming files in dir

by larus (Acolyte)
on Mar 19, 2009 at 09:17 UTC ( #751652=note: print w/replies, xml ) Need Help??

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

Well, I tried this
foreach my $file (@fileet) { my $newfile = 0; $newfile =~ s/ä//g; $newfile =~ s/ö//g; move("$file", "$path/$newfile"); }
but this produces no output. What I'm doing wrong here?

Replies are listed 'Best First'.
Re^3: Renaming files in dir
by Utilitarian (Vicar) on Mar 19, 2009 at 10:18 UTC
    foreach my $file (@fileet) { my $newfile = $file; $newfile =~ s/ä//g; $newfile =~ s/ö//g; move("$file", "$path/$newfile"); }
      Thanks, there is still a problem, because this code does not rename those files. What should I do?
      #!/bin/perl #usage: #C:\Perl>perl "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"); }
        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");

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://751652]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2017-02-22 22:30 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (338 votes). Check out past polls.