in reply to how to rename all files in a dir
use strict; use File::Copy qw ( move ); my $dirname = "./temp"; # dir you want to open; my $iterator = 0; opendir (DIRHANDLE, $dirname) or die "could not open dir: $!"; foreach (readdir(DIRHANDLE)) { #need to add path my $filename = $dirname . "/$_"; next unless -f $filename; move ($filename, $dirname . "/" . $iterator++) or warn "could not +rename file"; }
--
flounder
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: how to rename all files in a dir
by BrowserUk (Patriarch) on Jul 07, 2002 at 05:01 UTC | |
by jjohn (Beadle) on Jul 07, 2002 at 13:04 UTC | |
by Aristotle (Chancellor) on Jul 07, 2002 at 12:40 UTC | |
by blakem (Monsignor) on Jul 07, 2002 at 12:27 UTC | |
by oakbox (Chaplain) on Jul 07, 2002 at 14:37 UTC |