Apr-14-2019, 09:09 AM
Hi Francisco
Play around with the following script:
Play around with the following script:
import os, sys from stat import * def walktree(top, callback): '''recursively descend the directory tree rooted at top, calling the callback function for each regular file''' for f in os.listdir(top): pathname = os.path.join(top, f) mode = os.stat(pathname).st_mode if S_ISDIR(mode): # It's a directory, recurse into it callback(os.path.basename(pathname), "Directory") walktree(pathname, callback) elif S_ISREG(mode): # It's a file, call the callback function callback(os.path.basename(pathname), "File") else: # Unknown file type, print a message print('Skipping %s' % pathname) def walktree_callback(item_name, item_type): print("{}: {}".format(item_type, item_name, )) if __name__ == '__main__': startdir = os.getcwd() # Here place your own startdir path! walktree(startdir, walktree_callback)wuf :-)