You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
735 B

#!/bin/python
import os
# Get directory path of currently executed script
# E.g. /home/natascha/uni/python/test.py -> /home/natascha/uni/python
# This always yields the above, no matter from which path the script is executed
script_dir = os.path.dirname(os.path.realpath(__file__))
# Join the script_dir with the directory which holds the data files
#
# /home/natascha/uni/python
# ├── data
# │ ├── data.txt
# │ └── media.txt
# └── test.py
#
# data_dir -> /home/natascha/uni/python/data
data_dir = os.path.join(script_dir, 'data')
# Traverse the data directory and print out the filenames with path
for root, cur_dir, files in os.walk(data_dir):
for f in files:
print(os.path.join(root, f))