rejetto forum
February 09, 2012, 04:45:47 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: a method to get folder size  (Read 6974 times)
0 Members and 1 Guest are viewing this topic.
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« on: January 27, 2009, 04:09:24 AM »

Hello, i came to this idea

ABSTRACT:
method to display the folder size instead of just folder.

LIMITATIONS:
1. It works only for real folders.
2. it won't care of files/folders filter that may actually reduce the stuff shown by your HFS.
3. This is thought essentially for large folders, that you must decide when the size should be refreshed. It's not fully automatic.

METHOD:

step 1. make a batch file like this

FOR %%s IN ("C:\music";"C:\my other folder")
DO du.exe -m -s %%s > %%s\foldersize & attrib +h %%s\foldersize

you can find du.exe in a package at http://unxutils.sourceforge.net/
(attached at bottom for your convenience)

step 2. put this in the diff template of the root, in HFS

Code:
[folder]
{.$item start.}
<td align='center'>
{.set|size|{.load|%item-resource%\foldersize.}.}
{.if|{.^size.}|{.substring|| |{.^size.}.} MB
|<i>folder</i>.}
<td align='right'>%item-modified%<td align='right'>%item-dl-count%

CONCLUSIONS:
i'm not actually using this, but i thought it would be good to share it, and maybe you can improve it. Wink

* du.exe (25.5 KB - downloaded 236 times.)
Logged
Hari
Guest


Email
« Reply #1 on: June 04, 2009, 02:08:42 AM »

' ---------------------------------
' Hariprasad Radhakrishnan
' hradhakrishnan@gmail.com
' Save script as folder.vbs
' Run script from cmd prompt C:\Scripts\cscript folder.vbs >FolderSize.txt  OR
' Run script from cmd prompt C:\Scripts\cscript folder.vbs  OR
'----------------------------------


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSubfolders = objWMIService.ExecQuery _
 ("ASSOCIATORS OF {Win32_Directory.Name='C:\'} " _
 & "WHERE AssocClass = Win32_Subdirectory " _
 & "ResultRole = PartComponent")

For Each objFolder in colSubfolders
'Loop Begins

'Echo Folder Name
 Wscript.Echo objFolder.Name
On Error Resume Next

'Pass Folder Name from WMI to FSO - Hari

objfsoFolder = "" & objFolder.Name & ""
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(objfsoFolder)

'Covert objFolder size from bytes to GB
FolderSizeGB = formatnumber(objFolder.Size / (1024 * 1024 * 1024),2)

'Echo foldersize
Wscript.Echo "Folder Size = " & FolderSizeGB & " GB"

'Wscript.Echo "Folder Size = " & objFolder.Size & " Bytes"

'Counter for Number of Folders
Fcount=Fcount+1

Next
'Loop Ends

'Echo Total Folder Count
Wscript.Echo "Total Folders:  " & Fcount




Logged
Rygrass
Guest


Email
« Reply #2 on: May 09, 2010, 02:06:05 AM »

I can't seem to get this to work
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« Reply #3 on: May 10, 2010, 10:46:10 AM »

you should tell something more if you want help
Logged
LightBright
Occasional poster
*
Offline Offline

United States United States

Posts: 5


View Profile
« Reply #4 on: July 27, 2010, 03:08:22 PM »

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strWindowsdir & "\explorer.exe")
MsgBox("file size = " & f.size)
Logged
r][m
Insane poster
*****
Offline Offline

United States United States

Posts: 339


View Profile
« Reply #5 on: July 29, 2010, 08:22:55 AM »

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strWindowsdir & "\explorer.exe")
MsgBox("file size = " & f.size)
@ LightBright
Could you give example about how and where to use this with HFS?
Logged
rejetto forum
« Reply #5 on: July 29, 2010, 08:22:55 AM »

Do you like this software? Consider even $2
 Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« Reply #6 on: July 30, 2010, 07:57:50 AM »

i guess it's a .vbs script...?
Logged
Hari
Guest


Email
« Reply #7 on: October 11, 2010, 08:37:49 AM »

Attached the script for csv output

* folder.txt (1.34 KB - downloaded 185 times.)
Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 189



View Profile WWW
« Reply #8 on: August 09, 2011, 09:36:48 PM »

But then how can HFS be used to capture the output of that VBS script?
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« Reply #9 on: August 22, 2011, 01:44:27 PM »

by using the "out" parameter of {.exec.} command
Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 189



View Profile WWW
« Reply #10 on: September 18, 2011, 11:05:12 AM »

Can you give me an example?
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« Reply #11 on: October 04, 2011, 04:42:44 AM »

{.exec|ipconfig|out=#x.}
{.^#x.}
Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 189



View Profile WWW
« Reply #12 on: October 17, 2011, 08:50:15 PM »

I GOT IT !!!!!!   I'm not sure if this slows down the page load though....

Under [folder=file], put

Code:
{.if not|{.=|%item-size%|0.}|{:
{.set|foldersize|.}
{.set|vfsdir|{.vfs to disk|%url%%item-name%.}.}
{.save|C:\foldersize.bat|
@D:
@cd "{.^vfsdir.}"
@For /F "tokens=*" %%a IN ('"dir /s /-c {.no pipe||.} find "bytes" {.no pipe||.} find /v "free""') do @Set summaryout=%%a
@For /f "tokens=1,2 delims=)" %%a in ("%summaryout%") do @set filesout=%%a&set sizeout=%%b
@Set sizeout=%sizeout:bytes=%
@Set sizeout=%sizeout: =%
@Echo %sizeout%
.}
{.exec|C:\foldersize.bat|out=sizeresult.}{.set|foldersize|{.round|{.div|{.div|{.^sizeresult.}|1024.}|1024.}|2.} {.if|{.^sizeresult.}|MB.}.}
:}.}

and then under the size column put

Code:
{.if|{.^foldersize.}|{:{.^foldersize.}:}|{:%item-size%:}.}

  Smiley
« Last Edit: October 17, 2011, 08:59:25 PM by raybob95 » Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« Reply #13 on: October 18, 2011, 08:28:34 AM »

but... is this script meant to run every time i load the page?


a side note about scripting. You wrote
{.if not|{.=|%item-size%|0.}|
since 0 is considered false, then this is equivalent to
{.if not|{.not|%item-size%.}|
that is equivalent to
{.if|%item-size%|
that's nice and lighter
Logged
raybob
Tireless poster
****
Offline Offline

United States United States

Posts: 189



View Profile WWW
« Reply #14 on: October 18, 2011, 02:31:52 PM »

Yeah that's the thing it runs every time the page loads.
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page February 08, 2012, 02:59:31 AM
anything