A Little Python Script for Website Files
Before uploading a folder of pages, it helps to have a list of the HTML files it contains. This retro exercise uses simple Python syntax from the Python 2.2 era to print a list. The same script runs on modern Python 3.
Save this as list_pages.py in a folder containing a few HTML files:
import os
names = os.listdir(".")
names.sort()
for name in names:
if name.lower().endswith(".html") and os.path.isfile(name):
print(name)
Open a terminal in that folder and run python3 list_pages.py with a current Python installation. With about.html and index.html present, you should see those names in alphabetical order. Add a notes.txt file and try again. It stays off the list.
The dot in os.listdir(".") refers to the current working directory. If you run the script from somewhere else, it lists files there instead. This version looks only in that one directory, which is useful when all the pages you plan to upload are together.