-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.pl
67 lines (58 loc) · 1.25 KB
/
search.pl
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/local/bin/perl
##############################################################
# directory run script
# 2004/11/4
# powered by Masashi Okada
##############################################################
$path = "/Users/okada/Desktop/"; #CHANGE root directory
@path = "/Users/okada/Desktop/"; #CHANGE root directory
$path_back = "";
$flag = "off";
$dir = "";
$directory = "";
$count = 0;
$m = 0;
$n = 0;
PATH:
$flag2 = "on";
if ($count eq 0){}
else{
@path = split /,/,$dir;
}
$dir = "";
foreach $path (@path){
$count = split /\//,$path;
$count = $count - 3; #CHANGE
$path_back = "";
$flag = "off";
print "$path\n";
opendir(DIR,$path) or die "error";
chdir $path;
while ($entry = readdir DIR){
if (-d $entry){
if (($entry eq ".") or ($entry eq "..")){next;}
else{}
$directory = "$path/$entry";
$dir = "$directory,$dir";
$flag = "on";
print "$directory \n";
}
else{
@stat = stat $entry;
$file = $file + $stat[7];
}
}
for($m = 1;$m < $count;$m++){
$path_back = "../$path_back";
}
print "$path_back\n";
if ($count eq 1){}
else {chdir $path_back;}
}
if ($flag eq "on"){
goto PATH;
}
else{}
$file = $file / 1048576;
print "$file MB\n";
exit;