I have found many methods to list every file in multiple directories, like so:
root = "C:\\test\\"
for path, subdirs, files in os.walk(root):
for name in files:
print(os.path.join(path, name))
However, I need to list only one file in each directory. I am not looking for any particular order, but I do not need randomness either. Is there a way to get a single file (preferably the "first") in each directory to save the resources it would take to list every file? (This is a Windows filesystem, if that is relevant.)
if files: print(files[0])