use strict; use File::Find; my $source = 'c:/directory'; my $folders = 0; my $files = 0; $File::Find::dont_use_nlink = 1; # to fix a bug in File::Find File::Find::find( sub { if (-f $File::Find::name) { $files++ } elsif (-d $File::Find::name) { $folders++ }; }, $source ); print "Summary of $source\n"; print "Folders: $folders\n"; print "Files: $files\n";
Also note how my code has a different background and a "download" link. This is because I wrapped it in <code>...</code> tags instead of using <pre> tags. PRE tags are kind of frowned upon here - see the Writeup Formatting Tips for further information.
In reply to Re: Count folder/files in directory
by Corion
in thread Count folder/files in directory
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |