|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
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
|
|
|
|
Joined: Dec 2004
Posts: 81
Babel fish
|
Babel fish
Joined: Dec 2004
Posts: 81 |
Here's a snippet from FiberOptics (I wrote one, then he wrote it better ;P)
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)
}
}
}
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
well I knew $findfile was slower than some other methods, but I tested it with this
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
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Thanks. I thought there was probably a method using $com.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
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
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
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.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
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.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
OP
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.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
|