skip to main
|
skip to sidebar
Codeape
Pages
Home
About
Sunday, May 15, 2011
Python count files in dirs program; better ls | wc -l (word count)
#!/usr/bin/python
import os
from os.path import join, getsize
for root, dirs, files in os.walk('.'):
print root, "consumes",
print sum(getsize(join(root, name)) for name in files),
print "bytes in", len(files), "non-directory files"
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Blog Archive
►
2018
(1)
►
May
(1)
►
2012
(1)
►
January
(1)
▼
2011
(37)
►
December
(1)
▼
May
(3)
ssh-keygen instructions for windows (tortise, putt...
Commandline to samba mount linux to a windows share
Python count files in dirs program; better ls | wc...
►
April
(8)
►
March
(7)
►
February
(6)
►
January
(12)
►
2010
(60)
►
December
(9)
►
November
(4)
►
October
(3)
►
September
(3)
►
August
(6)
►
July
(4)
►
June
(1)
►
May
(11)
►
March
(2)
►
February
(4)
►
January
(13)
►
2009
(15)
►
December
(5)
►
November
(10)
Search This Blog
No comments:
Post a Comment