Skip to content

Instantly share code, notes, and snippets.

@XDo0
Last active July 21, 2022 12:45
Show Gist options
  • Save XDo0/a6d714cdd18170accf4636b6a4d29f36 to your computer and use it in GitHub Desktop.
Save XDo0/a6d714cdd18170accf4636b6a4d29f36 to your computer and use it in GitHub Desktop.
python:get files in the directory which includes several subdirectories
# Only one-level subfolders are supported
import os
def get_files(DIR):
file_list=list()
for sub_dir in os.listdir(DIR):
if os.isdir(sub_dir):
for file in os.listdir(os.path.join(DIR,sub_dir)):
file_list.append(file)
return file_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment