mIRC Home    About    Download    Register    News    Help

Print Thread
Getting sizes of directories #135082 07/11/05 07:16 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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?


Invision Support
#Invision on irc.irchighway.net
Re: Getting sizes of directories #135083 07/11/05 07:38 PM
Joined: Dec 2004
Posts: 81
N
nycdiesel Offline
Babel fish
Offline
Babel fish
N
Joined: Dec 2004
Posts: 81
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)
    }
  }
}

Re: Getting sizes of directories #135084 07/11/05 07:57 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
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

Re: Getting sizes of directories #135085 07/11/05 08:07 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Thanks. I thought there was probably a method using $com. laugh


Invision Support
#Invision on irc.irchighway.net
Re: Getting sizes of directories #135086 07/11/05 11:08 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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

Re: Getting sizes of directories #135087 08/11/05 02:03 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
Re: Getting sizes of directories #135088 08/11/05 02:09 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
Re: Getting sizes of directories #135089 08/11/05 02:16 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I had already done the search for "dirsize" and found your $foldersize script on here and that is what I ended up using. smile


Invision Support
#Invision on irc.irchighway.net