#157638 - 2006-02-27 03:25 PM
Re: Folders sorted by size
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
Yes, thats works. Is there a way to format the output in MB instead of bytes ? My whole script is formatted with the "FormatNumber" expression while writing results to a textfile.
WRITELINE (1, $item[0] + " " + $item[1] + @CRLF)
|
Top
|
|
|
|
#157642 - 2006-02-28 09:51 AM
Re: Folders sorted by size
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
When I run my script, I got all homedirs and their sizer. That's good. But is it possible to limit the number of items to, lets say 10 ? So only the top-10 of the biggest folders will be reported ?
|
Top
|
|
|
|
#157647 - 2006-02-28 11:48 AM
Re: Folders sorted by size
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
I'm sorry, I thought my firt question was clear:
Quote:
I want to scan the size of the users HomeDirs in our HomeDirs folder, sort all folders by size and write the 3 biggest folders' name and size in a textfile.
So, now I have almost all of it, only the selection of the 10 biggest folders (okay, instead of 3) is missing.
Using counters ? I'm afraid I do not know how to do so. If I did, I wouldn't be asking on this forum, would I?
|
Top
|
|
|
|
#157649 - 2006-02-28 12:16 PM
Re: Folders sorted by size
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
OK, I understand the meaning of $Counter, but I'm not sure where to put in in my script. I've tried serval places without any luck. Could you please tell me where to put int in ?
********* break on call 'quicksort.udf' call 'dirplus.udf'
OPEN (1, "E:\Script\HomeSize @MDAYNO @MONTH @YEAR.txt",5)
$root = dirplus('$HomeDirsLocation','/ad')
dim $folders[ubound($root)]
for $i = 0 to ubound($root) $n = $root[$i].name $s = val($root[$i].size) $folders[$i] = $n,$s next
$folders = quicksort($folders,1)
For $i = UBound($folders) To 0 Step -1 $item=$folders[$i] $item[0]+" "+$item[1]+@CRLF WRITELINE (1, $item[0] + " " + FormatNumber (CDbl($item[1]/1024/1024),0) + " MB" + @CRLF) Next
**********
|
Top
|
|
|
|
#157651 - 2006-02-28 12:29 PM
Re: Folders sorted by size
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
I'm sorry Jooel, I replaced
For $i = UBound($folders) To 0 Step -1
by
For $i = 9 To 0 Step -1
but this gives me a result of all homedirs sizes of 0MB...
|
Top
|
|
|
|
#157652 - 2006-02-28 12:53 PM
Re: Folders sorted by size
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Try this: Code:
$iLimit=UBound($Folders)-9 If $iLimit<9 $iLimit=UBound($Folders) EndIf For $i = UBound($folders) To $iLimit Step -1 $item=$folders[$i] $item[0]+" "+$item[1]+@CRLF $=WriteLine(1, $item[0] + " " + FormatNumber (CDbl($item[1]/1024/1024),0) + " MB" + @CRLF) Next
|
Top
|
|
|
|
#157653 - 2006-02-28 12:59 PM
Re: Folders sorted by size
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
You are a scripting hero.
Now everything works exactly the way I wanted. Thank you all you guys for your help and patience !
|
Top
|
|
|
|
#157655 - 2006-02-28 01:16 PM
Re: Folders sorted by size
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
Don't bother, you were all great help. Could not do it without you !
|
Top
|
|
|
|
#157656 - 2006-03-23 11:44 AM
Re: Folders sorted by size
|
BunzyBuddy
Fresh Scripter
Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
|
Last question: In my script I'm first scanning all HomeDirs and writing the results to my textfile. After that I'm scanning the GroupsDirs and also writing the results to the textfile. But, when a HomeDirectory's size is bigger than one of the GroupsDirs, it appears in the GroupsDirs result list.
So, is there a command to clear the "cache" after having scanned the Homedirs ?
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 369 anonymous users online.
|
|
|