mikevanhoff has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl open (FILE, "/Scripts/rotlog"); my @lines = <FILE>; close FILE; foreach $element (@lines) { # open the directory for reading opendir(REP, "$element") || die "Cannot open the directory $element $ +! "; 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"; # Place +a heading in the file. # 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"); #do not remove t +he images directory `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: Execute error on opendir
by no_slogan (Deacon) on Aug 14, 2002 at 14:45 UTC | |
by mikevanhoff (Acolyte) on Aug 14, 2002 at 14:54 UTC | |
|
Re: Execute error on opendir
by stajich (Chaplain) on Aug 14, 2002 at 13:59 UTC | |
by mikevanhoff (Acolyte) on Aug 14, 2002 at 14:07 UTC | |
by hmerrill (Friar) on Aug 14, 2002 at 14:38 UTC | |
by mikevanhoff (Acolyte) on Aug 14, 2002 at 14:48 UTC | |
by waswas-fng (Curate) on Aug 14, 2002 at 14:15 UTC | |
by mikevanhoff (Acolyte) on Aug 14, 2002 at 14:38 UTC |