[BangPypers] parsing directory and subdirecties
Senthil Kumaran
orsenthil at gmail.com
Thu Nov 18 10:44:55 CET 2010
On Thu, Nov 18, 2010 at 10:46:47AM +0530, Kenneth Gonsalves wrote:
> >
> > Check if os.walk() is useful.
>
> but that is looping - which he does not want.
Then he can wrap python over 'find -type f |wc -l'
- Provided he is on POSIX and wants to just count the files.
os.system('find -type f |wc -l')
OR
proc1 = subprocess.Popen(['find','-type','f'],stdout=subprocess.PIPE)
proc2 = subprocess.Popen(['wc','-l'],stdin=proc1.stdout,stdout=subprocess.PIPE)
out,err = proc2.communicate()
More information about the BangPypers
mailing list