home
clear breadcrumbs
search
login
 
getting contents of directory recursively
import os ,sys f = open("files.txt", "w") root = "/media/pete/2tb/backup/digital-ocean/music" path = os.path.join(root, "music") for path, subdirs, files in os.walk(root): for name in files: #print(os.path.join(path, name)) str = os.path.join(path, name) f.write(str + "\n")