Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^4: Renaming files in dir

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

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 "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");

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://751666]
[chacham]: i'm reading an article on and thee is a disturbing message on the bottom right that says, "Fork me on GitHub". Maybe i just have a dirty mind.
[choroba]: Check the ninja on
[chacham]: oh my...
[Corion]: choroba++ # fixed width
marto has a Dirty_Mind on vinyl
[Corion]: Heh. The upside of this phone call was at least commendations from my cow-orkers on how clam I stayed and how I always brought the topic back to my priorities and the established processes of $work (them only getting half of the conversation).

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-08-17 13:02 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (287 votes). Check out past polls.