This is a simple script that creates a list of names for the files/folder within the same directory and outputs it to a text file. The name of the output text file is needed as a parameter. Created and Tested on Windows OS.
Note(s):
-The python script name itself is excluded.
-Possible improvement is to have the script run a recursive function to search through the folders within the main directory and return sub file/folder names. (See https://github.com/homerflander/List-Directory-File-NamesV2)
-Created and Tested on Windows OS.
--------------------Demonstration--------------------
Command Prompt, Looking at the Test Folder Main Directory:
File Explorer, Looking at the Test Folder Main Directory:
Incorrect Parameters Attempts, Error Message Given:
1."python ListDirFileNames.py" lacks the name of the output text file.
2."python ListDirFileNames.py output1.txt output2.txt" has one too many output text file paramters.
Correct Parameters Attempt, Script Ran and Successful:
File Explorer/Command Prompt, Check that Output Text File is Created:
Command Prompt/Text File, Check that the Output Text File is Correct:
homerflander/List-Main-Directory-File-Names
This is a simple script that creates a list of names for the files/folder within the same directory and outputs it to a text file. The name of the output text file is needed as a parameter. Created and Tested on Windows OS.
Python