Differences between revisions 1 and 2
Revision 1 as of 2008-11-17 14:50:36
Size: 156
Editor: anonymous
Comment:
Revision 2 as of 2008-11-17 15:36:13
Size: 475
Editor: KorFreier
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:


{{{#!python
#!/usr/bin/env python
import os,fnmatch,sys

# Usage:
# ./walkdir.py directory extension

dir=sys.argv[1]
ext=sys.argv[2]
for root, dirs, files in os.walk(dir):
    f=fnmatch.filter(files,'*.'+ext)
    if type(f)==type([]):
        for fi in f:
            print root+os.path.sep+fi
}}}

   1 #!/usr/bin/env python
   2 import os,fnmatch,sys
   3 
   4 # Usage:
   5 # ./walkdir.py directory extension
   6 
   7 dir=sys.argv[1]
   8 ext=sys.argv[2]
   9 for root, dirs, files in os.walk(dir):
  10     f=fnmatch.filter(files,'*.'+ext)
  11     if type(f)==type([]):
  12         for fi in f:
  13             print root+os.path.sep+fi

LehreWiki: Python/Exercise3/Group2 (last edited 2008-11-24 09:54:06 by AnjaRoesel)