You have to use the `/b` switch (to write file list only, without header and other informations).
dir /b >> list.txt
Then if you need to list all `.exe` files in `c:\windows` the full command is:
dir c:\windows\*.exe /b >> list.txt
Please note that `>>` will **append** the list to the file. Do not forget you can use multiple search patterns, for example:
dir *.jpg;*.png /b > list.txt
It'll write all the `.jpg` and `.png` files (only names, without path or any other informations) to the file `list.txt` (overwriting the file if it did exist before).
If you need to exclude directories you can rely on `/a` switch (to include/exclude items according to an attribute). In your case you want to exclude directories then you have to use `-d`:
dir /b /a-d >> list.txt
Finally do not forget `dir` can be used recursively with `/s` switch (to list files that match search pattern in the given directory and in all sub-directories) and sorted with `/o` option. Use `dir /?` for more details about that.