Get folder and file names in batch on Windows

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”

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.

Leave a Reply to Ink Say Cancel reply

Your email address will not be published. Required fields are marked *