|
|
|||||||
Hi, Can anyone point me in the right direction for reading the size of a directory? Many Thanks |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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... |
||||||||
|
|
|||||||
tried getfilesize but only seemed to work on files not dir's. The dir's will be larger than 2GB |
||||||||
|
|
|||||||
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" ? |
||||||||
|
|
|||||||
Is this larger than 2GB? |
||||||||
|
|
|||||||
witto, it is, but what is your point? |
||||||||
|
|
|||||||
Originally Posted By: Jooel but remember, that has the same limit as getfilesize() that is, 2GB |
||||||||
|
|
|||||||
yes, but you are using wscript, not kixtart. so your example doesn't count. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
Vartype() shows a 5 for $objFolder.Size. Double? |
||||||||
|
|
|||||||
might be, or float. whats vartypename()? |
||||||||
|
|
|||||||
Double Anyway, I looked for Vartype() in kix2010.doc |