DOS command question.

Mears

Platinum Member
Mar 9, 2000
2,095
1
81
I'm trying to print a directory listing into a file so I can print out the filenames a directory contains. Any ideas on how to do that?
 

pac1085

Diamond Member
Jun 27, 2000
3,456
0
76
try 'dir > file.txt'

i dunno if this works in dos, but if it doesnt then no harm done
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
dir > foo.txt for all files and folders

dir /ad > foo.txt for all directories only.
 

KingNothing

Diamond Member
Apr 6, 2002
7,141
1
0
dir c:\windows > c:\file.txt

type dir /? to see options, there's switches for no extended information, recurse subdirectories, etc.
 

ScottMac

Moderator<br>Networking<br>Elite member
Mar 19, 2001
5,471
2
0
C:\>tree /?

Graphically displays the folder structure of a drive or path.

TREE [drive:][path] [/F] [/A]

/F Display the names of the files in each folder.
/A Use ASCII instead of extended characters.

tree /f |more for a paged listing
tree /f >lpt1: for hard copy

The root of the tree will be the current directory or the specified path.


FWIW

Scott
 

Mears

Platinum Member
Mar 9, 2000
2,095
1
81
Man do I feel like an idiot. I knew the > and < operators worked in *nix, but for some reason I didn't think they worked in DOS. Thanks for all the replies.