Page 1 of 1 1
Topic Options
#171076 - 2006-12-05 11:34 PM Directory Size
mikeyhoward Offline
Lurker

Registered: 2005-12-06
Posts: 4
Hi,

Can anyone point me in the right direction for reading the size of a directory?

Many Thanks

Top
#171077 - 2006-12-06 12:04 AM Re: Directory Size [Re: mikeyhoward]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Maybe like this: Hey, Scripting Guy! How Can I Connect to a Folder When There’s an Apostrophe in the Folder Name? (look at the last bit of code at the bottom)
Quote:
For example, if you want to know the size of Ken Myer’s Folder, use this code:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Ken Myer’s Folder")
Wscript.Echo "Size: " & objFolder.Size

Top
#171078 - 2006-12-06 12:09 AM Re: Directory Size [Re: Witto]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
but remember, that has the same limit as getfilesize()
that is, 2GB

[€dit]
hmm, doesn't getfilesize() work on folders too?
don't think I've ever tried that...


Edited by Jooel (2006-12-06 12:10 AM)
_________________________
!

download KiXnet

Top
#171079 - 2006-12-06 12:23 AM Re: Directory Size [Re: Lonkero]
mikeyhoward Offline
Lurker

Registered: 2005-12-06
Posts: 4
tried getfilesize but only seemed to work on files not dir's.

The dir's will be larger than 2GB

Top
#171081 - 2006-12-06 01:05 AM Re: Directory Size [Re: mikeyhoward]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, then you may need to change the output from witto's liner to something like:
Code:
$FSO = CreateObject("Scripting.FileSystemObject")
$Folder = objFSO.GetFolder("C:\Ken Myer’s Folder")
"Size: "  (0.0 + $Folder.Size) ?


or even:
"Size: " ((0.0 + $Folder.Size)/1024) "kB" ?
"Size: " ((0.0 + $Folder.Size)/1024/1024) "MB" ?
_________________________
!

download KiXnet

Top
#171172 - 2006-12-07 03:07 PM Re: Directory Size [Re: Lonkero]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Is this larger than 2GB?

Attachments
7-Size.PNG
Description:



Top
#171174 - 2006-12-07 03:43 PM Re: Directory Size [Re: Witto]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
witto, it is, but what is your point?
_________________________
!

download KiXnet

Top
#171185 - 2006-12-07 06:55 PM Re: Directory Size [Re: Lonkero]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Originally Posted By: Jooel
but remember, that has the same limit as getfilesize()
that is, 2GB

Top
#171195 - 2006-12-07 09:37 PM Re: Directory Size [Re: Witto]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yes, but you are using wscript, not kixtart.
so your example doesn't count.
_________________________
!

download KiXnet

Top
#171204 - 2006-12-07 11:47 PM Re: Directory Size [Re: Lonkero]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Whoops
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Program Files")
Wscript.Echo "Size: " & objFolder.Size

Code:
If NOT @LOGONMODE
	Break On
Else
	Break Off
EndIf
Dim $SO
$SO=SetOption("Explicit", "ON")
$SO=SetOption("NoMacrosInStrings", "ON")
$SO=SetOption("NoVarsInStrings", "ON")
$SO=SetOption("WrapAtEOL", "ON")
Dim $objFSO, $objFolder
$objFSO = CreateObject("Scripting.FileSystemObject")
$objFolder = $objFSO.GetFolder("C:\Program Files")
? "Size: " + $objFolder.Size


Attachments
8-SizeVBS.PNG
Description:

9-SizeKiX.PNG
Description:



Top
#171206 - 2006-12-07 11:56 PM Re: Directory Size [Re: Witto]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
damn, I remembered wrong.
k, that method works.
hmm...
the integer limit is 2,147,483,647
so the size method must return either string or double.
and kixtart translates the double (if it is double) right, which is odd as well. iirc, that wasn't the case in the past.
_________________________
!

download KiXnet

Top
#171208 - 2006-12-08 12:05 AM Re: Directory Size [Re: Lonkero]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Vartype() shows a 5 for $objFolder.Size.
Double?

Top
#171210 - 2006-12-08 12:11 AM Re: Directory Size [Re: Witto]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
might be, or float.
whats vartypename()?
_________________________
!

download KiXnet

Top
#171211 - 2006-12-08 12:20 AM Re: Directory Size [Re: Lonkero]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Double
Anyway, I looked for Vartype() in kix2010.doc

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 84 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.07 seconds in which 0.025 seconds were spent on a total of 16 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org