Batch File; List files in directory, only filenames

batch-file

This is probably a very simple question, but I'm having trouble with it. Basically, I am trying to write a Batch File and I need it to list all the files in a certain directory. The dir command will do this, but it also gives a bunch of other information; I want it to list ONLY the file names and exclude anything else.

I just want the output to look like this:

file1.txt
file2.txt
file3.txt

Thanks in advance!

Best Answer

The full command is:

dir /b /a-d

Let me break it up;

Basically the /b is what you look for.

/a-d will exclude the directory names.


For more information see dir /? for other arguments that you can use with the dir command.