Mar-20-2018, 01:18 PM
You use os.walk() which is recursive walking the whole tree.
Example:
Example:
import os for root, dirs, files in os.walk(r'E:\1\web_title'): for file in files: if file.endswith('.html'): print(file)
Output:Pipfile_1.html
Pipfile_2.html
Pipfile_3.html
join together then see that these files are in nested sub-folders.import os for root, dirs, files in os.walk(r'E:\1\web_title'): for file in files: if file.endswith('.html'): print(os.path.join(root, file))
Output:E:\1\web_title\Pipfile_1.html
E:\1\web_title\New folder\Pipfile_2.html
E:\1\web_title\New folder\New folder\New folder\Pipfile_3.html