Use os.system to execute a string and os.walk to get a recursive list of files


>>> def processdir(curdir,subdirs,files):
...     map(lambda f:os.system('\\cygwin\\bin\\wc -l "%s"' % f), 
[curdir+os.sep+x for x in files])
...
>>> map(lambda x:processdir(*x), os.walk('\\dev\qclient'));
6 \dev\qclient\.classpath
17 \dev\qclient\.project
774 \dev\qclient\bookmarks.html
8 \dev\qclient\kx\qclient\DirTree$1.class
20 \dev\qclient\kx\qclient\DirTree$2.class
17 \dev\qclient\kx\qclient\DirTree$3.class
8 \dev\qclient\kx\qclient\DirTree$4.class
18 \dev\qclient\kx\qclient\DirTree$5.class
9 \dev\qclient\kx\qclient\DirTree$CellRenderer.class
18 \dev\qclient\kx\qclient\DirTree$ServerPopupMenu.class
5 \dev\qclient\kx\qclient\DirTree$ServerTreeNode.class
28 \dev\qclient\kx\qclient\DirTree.class
148 \dev\qclient\kx\qclient\DirTree.java
11 \dev\qclient\kx\qclient\Q$Date.class
4 \dev\qclient\kx\qclient\Q$Dict.class
4 \dev\qclient\kx\qclient\Q$Flip.class
5 \dev\qclient\kx\qclient\Q$KException.class
12 \dev\qclient\kx\qclient\Q$Minute.class
12 \dev\qclient\kx\qclient\Q$Month.class
15 \dev\qclient\kx\qclient\Q$Second.class
18 \dev\qclient\kx\qclient\Q$Time.class
147 \dev\qclient\kx\qclient\Q.class
137 \dev\qclient\kx\qclient\Q.java
8 \dev\qclient\kx\qclient\QClient$1.class
11 \dev\qclient\kx\qclient\QClient$2.class
15 \dev\qclient\kx\qclient\QClient$3.class
9 \dev\qclient\kx\qclient\QClient$4.class
85 \dev\qclient\kx\qclient\QClient.class
185 \dev\qclient\kx\qclient\QClient.java
4 \dev\qclient\kx\qclient\QServer$DefaultListener.class
3 \dev\qclient\kx\qclient\QServer$Listener.class
28 \dev\qclient\kx\qclient\QServer.class
50 \dev\qclient\kx\qclient\QServer.java
59 \dev\qclient\kx\qclient\ServerDialog.class
146 \dev\qclient\kx\qclient\ServerDialog.java
14 \dev\qclient\kx\qclient\ServerDisplay$1.class
18 \dev\qclient\kx\qclient\ServerDisplay$StatusBar.class
19 \dev\qclient\kx\qclient\ServerDisplay.class
78 \dev\qclient\kx\qclient\ServerDisplay.java
[None, None, None]
>>>

KraftDiner wrote:
> Hi I need help writing a python script that traverses (recursivly) a
> directory and its sub directories and processes all files in the
> directory.  So at each directory if there are files in it I must build
> a list of those files and process them by exectuing a system command
> (exec?)
> 
> Can some one tell me what methods to use to:
> a) Walk the directory tree
> b) execute a system command with parameters.
> 
> TIA.
> 

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to