From: Chris Koeritz Date: Mon, 1 Oct 2012 23:56:48 +0000 (-0400) Subject: fixed errors for 3.2K and 5.8G style entries in directory. X-Git-Tag: 2.140.90~1207 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=28f75b2d4445afafb367335d0d32156ff3655e84;p=feisty_meow.git fixed errors for 3.2K and 5.8G style entries in directory. --- diff --git a/scripts/files/summing_dir.pl b/scripts/files/summing_dir.pl index 769a8f50..d23c5b48 100644 --- a/scripts/files/summing_dir.pl +++ b/scripts/files/summing_dir.pl @@ -65,17 +65,36 @@ local($lengths) = 0; # open the file and process the lines to get file lengths. open(DIRLIST, "<$temp_file"); +# we only want to match ls -al style output lines, and only want to keep the size. +$pattern="^[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +([0-9.]+[KMG]?).*\$"; foreach $file_line () { - (local $munged = $file_line) =~ s/^[^ ]* *[^ ]* *[^ ]* *[^ ]* *([0-9]+).*$/\1/; -# print "munge=$munged\n"; - $lengths += $munged; + if ($file_line =~ /$pattern/) { + (local $munged = $file_line) =~ s/$pattern/\1/; + #print "munge=$munged\n"; + if ($munged =~ /K$/) { + chop $munged; + $munged *= 1024.0; + #print "K munged is now $munged\n"; + } + if ($munged =~ /M$/) { + chop $munged; + $munged *= 1024.0 * 1024.0; + #print "M munged is now $munged\n"; + } + if ($munged =~ /G$/) { + chop $munged; + $munged *= 1024.0 * 1024.0 * 1024.0; + #print "G munged is now $munged\n"; + } + $lengths += $munged; + } } close(DIRLIST); unlink($temp_file); # clean up. #print "lens are: $lengths\n"; -local($total)=$lengths; +local($total)=int($lengths); local($kbytes)=int($total / 102.4) / 10; local($mbytes)=int($kbytes / 102.4) / 10;