Recursively walk a directory in Python

import os root = 'your root path here' # dirs are the directory list under dirpath # files are the file list under dirpath for dirpath, dirs, files in os.walk(root): for filename in files: fullpath = os.path.join(dirpath, filename) print fullpath
Recursively walk a directory using Python

#python #directory #file #recursive

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.