for entry in os.scandir(document_dir) if os.path.isdir(entry): # some code goes here else: # else the file needs to be in a folder file_path