mIRC Home    About    Download    Register    News    Help

Print Thread
#64851 22/12/03 04:06 PM
Joined: Feb 2003
Posts: 14
F
Pikka bird
OP Offline
Pikka bird
F
Joined: Feb 2003
Posts: 14
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?

#64852 22/12/03 06:07 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
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.

#64853 22/12/03 06:16 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#64854 22/12/03 06:29 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
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.

#64855 22/12/03 06:56 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#64856 22/12/03 07:01 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Unless $file($1-).size was returning 1 that would never happen.

#64857 22/12/03 07:03 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#64858 22/12/03 07:25 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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?

Last edited by KingTomato; 22/12/03 07:27 PM.

-KingTomato
#64859 22/12/03 07:54 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I dont think you can calc this to 1 gig: 7665 <<-- bytes or not wink


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#64860 22/12/03 08:49 PM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#64861 22/12/03 11:50 PM
Joined: Feb 2003
Posts: 14
F
Pikka bird
OP Offline
Pikka bird
F
Joined: Feb 2003
Posts: 14
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...

#64862 23/12/03 12:02 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Have you actually tried the code? The reason you gave that it won't work is nonsense since .echo -q stops it echoing anything.

#64863 23/12/03 12:16 AM
Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227
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)

#64864 23/12/03 05:55 AM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
#64865 23/12/03 09:50 AM
Joined: Feb 2003
Posts: 14
F
Pikka bird
OP Offline
Pikka bird
F
Joined: Feb 2003
Posts: 14
trust me.. this code doesnt work.. I also want to run it on a 120gb directory so 310 is still to high..

#64866 23/12/03 06:23 PM
Joined: Nov 2003
Posts: 227
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Nov 2003
Posts: 227

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

#64867 23/12/03 06:28 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
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.


Link Copied to Clipboard