xxxxxxxxxx
import os
# Replace 'your_directory_path' with the path to the directory you want to list
directory_path = 'your_directory_path'
# Check if the directory exists
if os.path.exists(directory_path) and os.path.isdir(directory_path):
# List all files in the directory
file_names = os.listdir(directory_path)
# Print the list of file names
for file_name in file_names:
print(file_name)
else:
print(f"The directory '{directory_path}' does not exist.")
xxxxxxxxxx
In MS Windows it works like this:
1 - Hold the "Shift" key, right-click the folder containing the files
and select "Open Command Window Here."
2 - Type "dir /b > filenames.txt" (without quotation marks) in the
Command Window.
3 - Inside the folder there should now be a file filenames.txt
containing names of all the files etc.