Hi there, this is my first python project. I'm new to python but I have experience in a few other languages.
I'm trying to export (to mysql) a list of files and subdirectories from several directories on my hard drive. Basically just so I can have an online database of the files on my hard drive.
Here is my recursive directory walker:
def getlist(path): for file in os.listdir(path): if os.path.isdir(os.path.join(path, file)): print os.path.join(path, file) getlist(os.path.join(path, file)) else: print file return
I was using os.walk beforehand, but couldn't figure out how to go dir->files dir->files, instead it was going dir->dir and THEN dir->files, if you understand.
Now I need some way to be able to keep the directory/file hierarchy while exporting to a mysql db. The only thing I could think of was for each dir to have an id but then I couldn't figure out what to do after that. Once it's done importing to the db, I will make a php/js page that will have a fancy display of all my folders/files. It needs to stay in it's current hierarchy because I will have collapsiblocks inside collapsiblocks (ie: files inside a dir inside a dir)
Thanks for any and all help.