Leser: 2
|< 1 2 3 >| | 27 Einträge, 3 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
sub GetFolderInfo
{
my @dirs = @_;
my (@allfiles, @files, @folders) = ();
my ($currdir, $file, $size, $measurement, $numfolders) = "";
while (@dirs != 0)
{
$currdir = pop( @dirs );
opendir( ENTRIES, "$currdir/" );
@allfiles = readdir( ENTRIES );
closedir( ENTRIES );
foreach $file (@allfiles)
{
if (-d "$currdir/$file")
{
push( @folders, "$currdir/$file" ) if (($file ne ".") && ($file ne ".."));
push( @dirs, "$currdir/$file" ) if (($file ne ".") && ($file ne ".."));
}
else
{
push( @files, "$currdir/$file" );
my $currfile = "$currdir/$file";
my $currsize = -s $currfile;
$size = $size + $currsize;
}
}
}
my $numfiles = @files;
my $numfolders = @folders;
$size = sprintf("%.2f",$size / 1024);
$measurement = "KB";
if ($size > 1024) {$size = sprintf("%.2f",$size / 1024); $measurement = "MB";}
if ($size > 1024) {$size = sprintf("%.2f",$size / 1024); $measurement = "GB - WARNING! THE FOLDER IS WAY TO BIG!";}
$size =~ y/./,/;
return "$size $measurement<br>$numfiles files<br>in $numfolders (sub)-folder(s)";
}
1
2
3
4
5
6
7
sub GetFolderInfo {
# [...]
return $size, $measurement, $numfiles, $numfolders;
# [...]
}
my @folder_infos = GetFolderInfo( './' );
1
2
3
4
5
6
7
8
9
sub GetFolderInfo {
# [...]
return {'size' => $size, 'measurement' => $measurement, # ....
};
# [...]
}
my $folder_infos = GetFolderInfo( './');
print $folder_infos->{size};
$ perl -MFile::Find -e 'find (sub{ $sum += -s unless /^\.\.?$/ }, @ARGV); print "$sum\n"' -- ./
QuoteAber aber warum nimmst du nicht File::Find (das ist doch ueberall vertreten)?
|< 1 2 3 >| | 27 Einträge, 3 Seiten |