DOS Command: create txt file that lists files in dir

cmosdos

2[H]4U
Joined
Aug 26, 2002
Messages
2,075
I need to print a list of all the files in a directory to a text file. I was pretty sure that you use the PRINT command but instead of specifying a printer, you specify a txt file. However this doesn't appear to be working. I think I'm just not using the correct syntax.

Also, I know its possible to do this in windows as well, but I have no clue how to do that. Any help on this would be very much appreciated!
 
Old school. Alright here you go:

Code:
dir > C:\test.txt

That'll output the result of the "dir" command in the current directory, to a text file called test.txt, etc.

Oh, you can also restrict output to a certain extension if you'd like:

Code:
dir C:\*.jpg > C:\test.txt
 
if you just want filenames (rather than all the other junk that gets listed with dir) do dir /b > list.txt
 
Xtasy0 said:
if you just want filenames (rather than all the other junk that gets listed with dir) do dir /b > list.txt

Perfect... now i don't have to edit out all the other stuff. With over 19K files in this directory I need to index into excell, this saves me hours of manual typing. Thanks again!
 
Thank god for the search.........This is just what I needed.
 
anyone know how to make the dir command recurse to subdirectories?

Peace

PS: if only DOS/windows had a MAN pages.... :p
 
Perrupa said:
anyone know how to make the dir command recurse to subdirectories?

Peace

PS: if only DOS/windows had a MAN pages.... :p


yea just use the /s parameter
 
Perrupa said:
anyone know how to make the dir command recurse to subdirectories?

Peace

PS: if only DOS/windows had a MAN pages.... :p

cmd.exe:
help dir

essentially the --help switch ;)
 
Back
Top