On Thu, Jul 26, 2001 at 01:42:11PM -0500, [EMAIL PROTECTED] wrote:
> #!/usr/bin/perl -w

You forgot use strict.  Always use strict when debugging code.


> #rename
> use File::Find;
> $DIRLIST = ('D:\PATH\To-Be Model\Data');
> find(\&process_file, $DIRLIST);
> rename_files();
> 
> sub process_file{
>       push (@files, $_);

$_ is just the filename, it's relative to $File::Find::dir, and
File::Find::find chdirs into $File::Find::dir.  $File::Find::name is the
full path.

        push (@files, $File::Find::name);

> };
> 
> sub rename_files{
>       foreach $file (@files) {
>       $newname = $file;
>       $newname =~ s/(.*)\.txt/$1\.dat/;

        $newname =~ s/\.txt$/.dat/;

>       rename($file, $newname) or 
>               warn "Couldn't rename $file to $newname: $!\n";
>       }
> };


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to