in reply to Re: Creating an array from a text file
in thread Creating an array from a text file
# open the directory for reading chdir "/opt/web/hr83tst/reports"; opendir(REP, "/opt/web/hr83tst/reports") || die "Cannot open the dire +ctory /opt/web/hr83/reports $! "; open(remlog,">/Scripts/dir-removed.log"); # open a file to keep as a +log of directories removed. print remlog "Directories removed this date : ",`date`, "\n"; # list the contents of the directory. These should be directories. while ($name = readdir(REP)) { if (-M $name >= 10) { print "$name\n" unless($name eq "images"); print remlog "$name\n" unless($name eq "images"); `rm -r $name` unless($name eq "images"); # THIS WILL REMOVE THE D +IRECTORY AND ALL OF ITS subdirectories and Files. } } close remlog; closedir(REP)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Creating an array from a text file
by insensate (Hermit) on Aug 14, 2002 at 15:24 UTC |