Hi,
I am using the below perl script to recursively read directories and sub directories and find out files which are of size zero and generate a log file for them.
But instead of simply generating a log file I want to create
e directories which it is reading and generate the log file in them.
For example My script is reading the directory structure as
Directory1 -> Sub directory1 ->Folder1 -> files
" " ->Folder2 -> files
" " ->Folder3 -> files
Directory2 -> Sub directory2 ->Folder1 ->files
" " ->Folder2 ->files
Thanks,#!/usr/local/bin/perl use File::Find ; use File::Basename; $search = shift || 'c:\Documents and Settings\user\Desktop\newbatch2' +; $outfile = 'c:\Documents and Settings\user\Desktop\newbatch\log.txt'; open OUTF, "> $outfile" or die print " can't create logfile; $!"; find sub { push @dirs, $File::Find::name if -d }, $search ; for $dir ( @dirs ) { opendir $dh, $dir or do { warn "Cannot open '$dir' $!" ; next ; } ; opendir( DIR, "$dir" ) ; @files = readdir( DIR ) ; closedir( DIR ) ; foreach $file ( @files ) { print " $dir\$file\n"; if ( -f "$dir/$file") { $filesize = -s "$dir/$file" ; if ( $file ne "empty.txt" && $file ne "sample.txt" ) { print OUTF "Warning: $dir/$file has size ZERO\n" if ( $filesize == "0" ) ; } } } closedir( $dh ) ; } close OUTF ; exit 0;
In reply to Perl Log File Help by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |