robertvari

tmp

Apr 27th, 2019
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. def get_all_files(folder, files=[]):
  2.     all_content = [os.path.join(folder, i) for i in os.listdir(folder)]
  3.  
  4.     # list files in current folder
  5.     files += [i for i in all_content if os.path.isfile(i)]
  6.  
  7.     subfolders = [i for i in all_content if os.path.isdir(i)]
  8.  
  9.     for f in subfolders:
  10.         get_all_files(f)
  11.  
  12.     return files
  13.  
  14. all_files = get_all_files(r"E:\Photos")
  15.  
  16. for f in all_files:
  17.     print(f)
Advertisement
Add Comment
Please, Sign In to add comment