I\'m just getting started with Python but already have found it much more productive than Bash shell scripting.
I\'m trying to write a Python script that will traverse e
Try it
import os
for item in os.walk(".", "*"):
print item
Try
info = []
for path, dirs, files in os.walk("."):
info.extend(FileInfo(filename, path) for filename in files)
or
info = [FileInfo(filename, path)
for path, dirs, files in os.walk(".")
for filename in files]
to get a list of one FileInfo
instance per file.
I'd use os.walk
doing the following:
def getInfos(currentDir):
infos = []
for root, dirs, files in os.walk(currentDir): # Walk directory tree
for f in files:
infos.append(FileInfo(f,root))
return infos