Python 3: working with files and digital assets/File/Traversal of a directory
Appearance
Traversal of a directory
[edit | edit source]OS Walk
[edit | edit source]from os import walk
from os.path import join
for root_directory, \
directories, \
files \
in walk(
'/home/jupyter',
topdown=False
):
# For all files found
for file in files:
full_path_to_file: str = join(
root_directory,
file
)
# For all directories found
for directory in directories:
full_path_to_directory: str = join(
root_directory,
directory
)