in reply to pushing file counts for adding
I made the below work on my web server. Will just be a few changes for you to make.
This is what the logfile had when it was done:#!/usr/bin/perl -T BEGIN { $| = 1; open(STDERR, ">&STDOUT"); print "Content-type: text/plain\n\n"; } my $dirfile = "/home2/jmelpubs/public_html/jimmelanson/programming/dow +nload/directory.txt"; my $log = "/home2/jmelpubs/public_html/jimmelanson/programming/downloa +d/logfile.txt"; my $global_file_count = 0; if(open(LOGFILE, ">$log")) { if(open(DIRS, '<:encoding(UTF-8)', $dirfile)) { my @directorylist = <DIRS>; close DIRS; foreach my $dir (@directorylist) { if($dir =~ /[a-zA-Z1-9]/) { chomp($dir); if ( -e "$dir/Thumbs.db") { unlink ("$dir/Thumbs.db") or print "thumbs.db $!\n +"; } opendir(READIT, $dir); my @files = readdir(READIT); closedir(READIT); my $directory_file_count = 0; foreach my $file (@files) { unless(($file eq ".") || ($file eq "..")) { $global_file_count++ unless(-d "$_/$file"); $directory_file_count++ unless(-d "$_/$file"); } } print LOGFILE "$dir : count is $directory_file_count\n +"; } } print LOGFILE "All directories count is $global_file_count\n"; close LOGFILE; } else { die "failed to open file for reading."; } close LOGFILE; } else { die "failed to open log file for writing."; } print "Final count is: $global_file_count\n"; exit;
I can't post test/script download on here. I'll try to PM that to you if you want it./home2/jmelpubs/public_html/jimmelanson/books : count is 7 /home2/jmelpubs/public_html/jimmelanson/downloads : count is 1 /home2/jmelpubs/public_html/jimmelanson/images : count is 18 All directories count is 26
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: pushing file counts for adding
by Anonymous Monk on Mar 21, 2016 at 23:01 UTC | |
by TorontoJim (Beadle) on Mar 21, 2016 at 23:11 UTC | |
by Anonymous Monk on Mar 21, 2016 at 23:25 UTC | |
by TorontoJim (Beadle) on Mar 22, 2016 at 10:22 UTC | |
by Anonymous Monk on Mar 22, 2016 at 11:07 UTC | |
by 1nickt (Canon) on Mar 22, 2016 at 14:10 UTC | |
by Anonymous Monk on Mar 22, 2016 at 10:43 UTC | |
|
Re^2: pushing file counts for adding
by TorontoJim (Beadle) on Mar 21, 2016 at 22:50 UTC |