There may be some situation where you want to find the list of all filenames whose patterns are like “*.txt”, “File*.csv”, “*.html”.., etc. In such scenario you can use the below command shell scripts to get the desired results which you are looking for.
1) To get the list of all filenames and folder names present in a folder “C:\testdata\”
cd "C:\testdata\"
dir /b /s
Output:-

2) To get all the filenames of pattern “*.txt” or “*.html” from folder “C:\testdata\”
dir /b /s "*.txt"
dir /b /s "*.html"
Output:-

3) To get all the filenames of pattern “*.txt” from folder “C:\testdata\” and store the corresponding results in the text document
dir /b /s "*.txt" > output.txt
dir /b /s "*.txt" > "c:\testdata\test\outputs.txt"
Output:-
