Tony,

This is my standard script for recursively walk folder structures.  You
should be able to adapt it, and use a command like 'system("adddomains.exe
$_");' once you have qualified the text file.

James

WalkFolder("@ARGV");

sub WalkFolder {
        local($dir) = shift;
        local($path);
        unless (opendir(DIR, $dir)) {
                print STDERR ("$dir\nError #", int( $! ), ": $!" );
                closedir(DIR);
                return;
        }
        foreach (readdir(DIR)) {
                next if $_ eq '.' || $_ eq '..';
                $path = "$dir\\$_";
                if (-d $path) {
                        if (chdir $path){
                                print STDOUT "Do Something With Folder:
\"$path\"\n";
                                WalkFolder($path);
                        } else {
                                print STDERR "ERROR: NO ACCESS To
\"$path\"\n";
                        }
                } elsif (-f $_) {
                        print STDOUT "Do Something With File: \"$_\"\n";
                }
        }
        closedir(DIR);
}
>From: perl 
>Sent: Monday, November 06, 2000 7:13 AM
>To: perl-win32-admin
>c: perl
>Subject: FW: Loop through directory looking for text files
>
>Hi
>
>I do something similar in a shell script on linux - how could I do this in
>.pl on NT:
>
>loop through a directory looking for *.txt files - then this adddomains.exe
>opens each text file and runs about 10 commands. (If i run adddomains.exe
>filename.txt it works fine - I just want to loop the directory for text
>files.
>
>============================
>for DIR *.txt
>do
>        adddomains.exe $DIR
>done
>============================
>
>Sorry normally shell scripts on Linux.
>
>Tony

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to