Getting the directory size

Mark Hammond mhammond at skippinet.com.au
Fri Jun 2 00:08:28 EDT 2000


"Pieter Claerhout" <PClaerhout at CREO.BE> wrote in message
news:2B1262E83448D211AE4B00A0C9D61B030130118F at msgeuro1.creo.be...
> Hi all,
>
> I want to be able to find the total size of a directory on my NT
machine,
> and I started with writing it using the os.path.walk function, and it
looks
> something like this:

I needed this too.  Attached is a program I wrote some time ago that walks
a directory tree and prints the size is its files, and the total size of
all children.  Its not that different to what the Unix du command can
dump.

It was cloned from my memory of an old utility I once had called
"dirsize" - dont know the origin or history of that tho.

Hope this is of some use.

Mark.


begin 666 dirsize.py
M:6UP;W)T(&]S#0II;7!O<G0@<W1A= T*:6UP;W)T('-Y<PT*:6UP;W)T(&=L
M;V(-"@T*;6%X4')I;G1,979E;#TW(",@<WES+FUA>&EN= T*#0ID968 at 0V%L
M8U-I>F4H9&ER+"!T:&ES3&5V96P],"DZ#0H);F%M97,@/2!G;&]B+F=L;V(H
M;W,N<&%T:"YJ;VEN*&1I<BP@(BHB*2D-"@ET:&ES4VEZ92 ](#!,#0H)8VAI
M;&1R96Y3:7IE(#T@,$P-"@EF;W(@;F%M92!I;B!N86UE<SH-"@D):68@;W,N
M<&%T:"YI<V1I<BAN86UE*3H-"@D)"6-H:6QD<F5N4VEZ92 ](&-H:6QD<F5N
M4VEZ92 K($-A;&-3:7IE*&YA;64L('1H:7-,979E;"LQ*0T*"0EE;'-E. at T*
M"0D)=&AI<U-I>F4@/2!T:&ES4VEZ92 K(&]S+G-T870H;W,N<&%T:"YJ;VEN
M*&1I<BP@;F%M92DI6W-T870N4U1?4TE:15T-"@ET;W1A;%-I>F4@/2!C:&EL
M9')E;E-I>F4@*R!T:&ES4VEZ90T*"6EF('1H:7-,979E;" \(&UA>%!R:6YT
M3&5V96PZ#0H)"6EF(&QE;BAD:7(I/C4X.B!D:7(@/2 B+BXN(B K(&1I<ELM
M-34Z70T*"0EP<FEN=" B)2TV,',E+3$P9"4M,3!D(B E("AD:7(L('1H:7-3
M:7IE(#X^(#$P+"!T;W1A;%-I>F4@/CX@,3 I#0H)<F5T=7)N('1O=&%L4VEZ
M90T*#0II9B!?7VYA;65?7ST])U]?;6%I;E]?)SH-"@EI9B!L96XH<WES+F%R
M9W8I/3TQ. at T*"0EP(#T@;W,N9V5T8W=D*"D-"@EE;'-E. at T*"0EI9B!S>7,N
M87)G=ELQ73T](BUL(CH-"@D)"6UA>%!R:6YT3&5V96P@/2!S>7,N87)G=ELR
M70T*"0D)<" ]('-Y<RYA<F=V6S-=#0H)"65L<V4Z#0H)"0EP(#T@<WES+F%R
M9W9;,5T-"@EP<FEN=" B)2TV,',E+3$P<R4M,3!S(B E("@B1&ER96-T;W)Y
M(BP@(E1H:7,@*&MB*2(L(")4;W1A;" H:V(I(BD-"@EP<FEN=" B)2TV,',E
M+3$P<R4M,3!S(B E("@B+2TM+2TM+2TM(BP@(BTM+2TM+2TM+2(L("(M+2TM
8+2TM+2TM(BD-"@E#86QC4VEZ92AP*0T*
`
end




More information about the Python-list mailing list