which is the result of marrying This script, that obtains the number of files and folders for a given path, to This one, that uses a multi-threading technique to ping few servers, so that instead of pinging servers the script will obtain the size, number of files and folders of a list of folders/paths/share…etc.$|++; AUTOLOAD; use strict; use warnings 'all'; use diagnostics; use Win32::OLE qw[in]; use threads; use threads::shared; my $fso = Win32::OLE->new( 'Scripting.FileSystemObject' ); my @childs; my @up: shared; for (@ARGV){ print "\n$_\n"; push @childs, threads->create("Process_path","$_"); #Process_path($_); } foreach my $child (@childs){ $child->join(); } print @up; sub Process_path{ my ($path) = @_; my @folders = $fso->GetFolder( $path); my $FSize = $fso->GetFolder($path); my $Size = $FSize->size(); print "Size: $Size\n"; my $fCount =0; my $sCount =0; while( @folders ){ my $folder = pop @folders; $fCount += $folder->Files->Count; $sCount += $folder->SubFolders->Count; for my $subFolder ( in $folder->SubFolders ) { $fCount += $subFolder->Files->Count; push @folders, $_ for in $subFolder->SubFolders ; $sCount += $subFolder->SubFolders->Count; }} print "Files : $fCount, folders : $sCount\n"; push (@up, $path.": ".$Size.": ".$fCount.": ".$sCount."."); }
Since this my first attemp with multithreading, I am not sure how to fix it.Free to wrong pool 1a9e940 not 223f80 at C:\Scripts\threads4_wsh.pl li +ne 29. Free to wrong pool 1ab0998 not 223f80 at C:\Scripts\threads4_wsh.pl li +ne 15.
In reply to Starting multi-threading by blackadder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |