mIRC Homepage
Posted By: Fredde87 Folder size - 22/12/03 04:06 PM
Hi

is there a way to calculate a folders size in mirc? I have done a script that uses a loop to calculate the size of each file in the folder but mirc will crash if the folder is over 1gb... Maybe there is a dll that does this?
Posted By: Collective Re: Folder size - 22/12/03 06:07 PM
Code:
alias dirsize {
  var %t = 0
  .echo -q $findfile($$1-,*,0,var %t = %t + $file($1-).size)
  return %t
}

Worked for me on a 2gb folder.
Posted By: sparta Re: Folder size - 22/12/03 06:16 PM
that code didnt work for me.. tryed on my Unreal Tournament dir.. the answer i got was: 639 .. but the size of that dir is 811 mb .. but the files inside the dir is 639 files, 19 folders wink
Posted By: Collective Re: Folder size - 22/12/03 06:29 PM
I don't know why that would be, it's a very basic script.

Try copying it again (I changed it a bit) and changing the name.

//echo -a $dirsize(c:\windows)

I got it to work on 6.01, 6.02, 6.03 and 6.12.
Posted By: sparta Re: Folder size - 22/12/03 06:56 PM
heh.. it count the files.. :P my win dir is 1 gig big.. but your litle script says: 7665 and thats right.. if i wanted to count the files in it wink
Posted By: Collective Re: Folder size - 22/12/03 07:01 PM
Unless $file($1-).size was returning 1 that would never happen.
Posted By: sparta Re: Folder size - 22/12/03 07:03 PM
all my files and folders return that.. if i use your code, and cant say why.. maybe it have somthing to do with windows 2k ?.. i didnt edir your code at all, just copyed it and pasted it in to my remote.. smile allways fun to test all codes that people write in this forums.. smile
Posted By: KingTomato Re: Folder size - 22/12/03 07:25 PM
Works for me collective, just so you don't think you're alone >:P

BTW, to those who don't have it working: you realise it's returning bytes, not kilobytes, megabytes, gigbytes, etc--right?
Posted By: sparta Re: Folder size - 22/12/03 07:54 PM
I dont think you can calc this to 1 gig: 7665 <<-- bytes or not wink
Posted By: sparta Re: Folder size - 22/12/03 08:49 PM
just took one post to reply wink somone that have a diffrent code then this abow? it doesnt work as it should "for me".. and i would like to know if you can solve it in som other way smile
Posted By: Fredde87 Re: Folder size - 22/12/03 11:50 PM
that code wont work... i have tried it before.. $findfile with the third parement as 0 will result in mirc showing how many files are in that directory..

this is the script I tried before...

alias sizechecker {
set %size.time $ctime
set %size.total 0
set %size.file 0
:next
set %size.file $calc(%size.file + 1)
if ($findfile(d:\,*,%size.file) == $null) { goto end }
set %size.total $calc(%size.total + $file($findfile(d:\,*,%size.file)).size)
goto next
:end
//echo ended $asctime($calc($ctime - %size.time),nn - ss) ago
//echo sharing $calc($calc($calc($calc(%size.total)/1024)/1024)/1024)/1024) GB
}

this works but seems to crash on folders with a lot of files in them..The script shouldnt take a lot of time to exacute either so probebly what I am looking for is a dll...
Posted By: Collective Re: Folder size - 23/12/03 12:02 AM
Have you actually tried the code? The reason you gave that it won't work is nonsense since .echo -q stops it echoing anything.
Posted By: Hitchhiker Re: Folder size - 23/12/03 12:16 AM
Though i would just say, I also can't see any reason for the alias not to work, and its about the fastest scripting way to do that, I tested it with a 6.5 GB dir and it ran in just 310 ms, went a little faster chaning the %t = %t + $file($1-).size for inc %t $file($1-).size but not much. (270ms)
Posted By: sparta Re: Folder size - 23/12/03 05:55 AM
i edited the code as you did. "inc %t $file($1-).size" and i get the same result.. the map i looking true is my mirc folder.. and the answer i get is: 368, and if i take properties of that map, then it's the files that are 368.. and by the way, i changed echo -q to echo -a smile
Posted By: Fredde87 Re: Folder size - 23/12/03 09:50 AM
trust me.. this code doesnt work.. I also want to run it on a 120gb directory so 310 is still to high..
Posted By: Hitchhiker Re: Folder size - 23/12/03 06:23 PM

i changed echo -q to echo -a

you edit somebodys code then tell them it does not work?
strange, because if you used echo -a and not .echo -q it would just echo the total number of files in the dir and all sub dirs...
.echo -q is used when you dont want to display something, he used that so you didnt see the number of files in the dir, though it should still return the total bytes of all files, you will see the total files first via the echo -a. maybe you should use the original code. smile
Posted By: Collective Re: Folder size - 23/12/03 06:28 PM
After reading Hitchiker's last post, I think you must be using it as a /command rather than a $identifier.

The /return is there because it is to be used as a $identifier.
© mIRC Discussion Forums