fileinfo - Python program to traverse directories and read file information -


i'm getting started python have found more productive bash shell scripting.

i'm trying write python script traverse every directory branches directory launch script in, , each file encounters, load instance of class:

class fileinfo:      def __init__(self, filename, filepath):         self.filename = filename         self.filepath = filepath 

the filepath attribute full absolute path root (/). here's pseudocode mockup i'd main program do:

from (current directory):      each file in directory,      create instance of fileinfo , load file name , path      switch nested directory, or if there none, out of directory 

i've been reading os.walk() , ok.path.walk(), i'd advice straightforward way implement in python be. in advance.

i'd use os.walk doing following:

def getinfos(currentdir):     infos = []     root, dirs, files in os.walk(currentdir): # walk directory tree         f in files:             infos.append(fileinfo(f,root))     return infos 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -