0

I need an alternative for os.walk() that search the files in this folder but NOT the subfolders. The code should give me the absolute path of the files included in the Inputlist and add it to the Outputlist.

This is what i have at the Moment. The Problem is, that all files are in the Chosen folder but also in the subfolders, but i only need one of them (the one in the Chosen folder). I can't delete double files in the list because they will have a different path (Name)

path=filedialog.askdirectory()
for root, dirs, files in os.walk(path):
    for x in Inputlist:
        if x in files:
            Outputlist.append(os.path.join(root, x))

Hope you can help me, thank you!

Laurids
  • 1
  • 1
  • You'll find everything you need here: https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory – olinox14 Aug 27 '19 at 10:07
  • 1
    Possible duplicate of [How to exclude directory in os.walk()?](https://stackoverflow.com/questions/55587663/how-to-exclude-directory-in-os-walk) – hiro protagonist Aug 27 '19 at 10:07

0 Answers0