mIRC Homepage
Posted By: Riamus2 Getting sizes of directories - 07/11/05 07:16 PM
Is there a quick method to get the total bytes in a directory + subdirectories without using a loop and $file to get the size of every single file and without using a batch file that does dir /s > file.txt and then get the second to last line for the data? Perhaps something with $com?
Posted By: nycdiesel Re: Getting sizes of directories - 07/11/05 07:38 PM
Here's a snippet from FiberOptics (I wrote one, then he wrote it better ;P)

Code:
alias dirsize {
  if !$exists($1) { return }
  var %a = a $+ $ticks, %b = b $+ %a
  .comopen %a Scripting.FileSystemObject
  if !$comerr {
    .comclose %a $com(%a,GetFolder,1,bstr,$1\,dispatch* %b)
    if $com(%b) {
      %a = $2     
      tokenize 46 $com(%b).result
      .comclose %b
      return $iif(%a,$bytes($1,%a),$1)
    }
  }
}
Posted By: MikeChat Re: Getting sizes of directories - 07/11/05 07:57 PM
well I knew $findfile was slower than some other methods, but I tested it with this
Code:
alias dirbyte {
  var %folder.spec = $sdir(*)
  var %count.time = $ctime
  var %null = $findfile(%folder.spec,*,0,var %folder.size = $calc(%folder.size + $file($1-)))
  echo -a Elapsed Time: $duration($calc($ctime - %count.time))
  echo -a %folder.spec has $bytes(%folder.size,m).suf
  echo -a Files in %folder.spec $findfile(%folder.spec,*,0)
}


Output:

Elapsed Time: 2secs
C:\mirc61\ has 223.66MB
Files in C:\mirc61\ 6403
after scanning mIRC folder once it sped up appreciably

so I scanned another folder that is smaller and has less files
Elapsed Time: 7secs
C:\DoReMix\ has 4.99MB
Files in C:\DoReMix\ 2773
Posted By: Riamus2 Re: Getting sizes of directories - 07/11/05 08:07 PM
Thanks. I thought there was probably a method using $com. laugh
Posted By: DaveC Re: Getting sizes of directories - 07/11/05 11:08 PM
Quote:
Here's a snippet from FiberOptics (I wrote one, then he wrote it better ;P)


tried //echo -a $dirsize(c:\temp) : $dirsize(c:\temp,b) : $dirsize(c:\temp,3)
: :

mIRC 6.16 on Microsoft Windows 2000 [Version 5.00.2195]

$com(%b).result was returning $null for all folders attempted on
Posted By: FiberOPtics Re: Getting sizes of directories - 08/11/05 02:03 PM
What ncydiesel gave you is incorrect, since he's not issuing the Size property on the object.

People, the code using COM that was posted here does not work. I have submitted one that does work on ms.org here:

$foldersize

@nycdiesel: I do not appreciate you putting erroneous code on the forum saying I wrote it, i did not write that code like that.
Posted By: FiberOPtics Re: Getting sizes of directories - 08/11/05 02:09 PM
The code nycdiesel gave you is incorrect, therefore it is logical you don't get any results returned. Try the snippet I posted right above this post.
Posted By: Riamus2 Re: Getting sizes of directories - 08/11/05 02:16 PM
I had already done the search for "dirsize" and found your $foldersize script on here and that is what I ended up using. smile
© mIRC Discussion Forums