We sometimes need to get the folder or file names in a directory of Windows operating system. It is of course tedious to copy them one by one. The fastest one is using a script to obtain them in batch. Below is the trick.
Create a text file, and put the little snippet (command) below into the text file:
DIR *.* /B >LIST.TXT
Then, save the text file with a file format (extension) .bat, say, get-file-name.bat.
After that, put the text file to any directory where you want to get file or folder names, and double click it, it runs automatically and generates the result in a new text file: LIST.TXT, which is also located within the same directory.
That is it, simple and efficient.
4 replies on “Get folder and file names in batch on Windows”
or dir /b *.* > list.txt
try dir /w /b *.* > list.txt to see what happens.
Wow, there are so many commands workable. Thanks for sharing.
BTW, for Linux OS, extract file names under the same directory is pretty easy, just list them by command using terminal. But for Windows, we need to do some extra work.
at Linux… the command is ‘ls’
Sure, for Linux OS, it is much powerful and easier to use commands.