DOS command>make text file listing of files in dir

Does there exist a DOS command that will result in a text file:

a) containing a list of the contents of a folder specified in the DOS command, preferably distinguishing between files and subfolders, and

b) saved as & at a specified name and path, e.g., C:\WINDOWS\DESKTOP\List.txt

–?
Somewhere in the dim, seldom-dusted nether reaches of my mind, I have a vague recollection of having once known how to do this. I could, of course, be wrong.

OH YEAH: If you know it, please be patient and highly specific in your instructions. I’m a Mac user and DOS commands that are chock full of “switches” always intimidate the hell out of me.

dir c:\folder]. /s > C:\windows\desktop\list.txt

The /s switch tells DOS to look at the contents of subdirectories (folders) as well. Here “folder” is the subdirectory being examined.

dir c:\folder*****.* /s > C:\windows\desktop\list.txt

That should be typo. Which law is this again? Gaudere’s?

dir c:\folder*.* /s /-v > C:\windows\desktop\list.txt

You want the -v switch in there so it doesn’t ask you to hit enter every time it needs to scroll a page off the top of the screen. This is particularly obnoxious when the prompt to do so is being redirected to a file.

Anth, yes I believe that is Gaudere’s law.

ultrafilter, I’m not sure what you mean; if you enter the command as I (re)typed it, you should see nothing on screen until you get the next blinking cursor.

beatle: It might depend on what version of DOS you’re using. I’d go out and look it up, but I’m using win2k, and I can’t find the DOS prompt. Over the summer, I had to do what I described to get this to work properly.

Well, one way or another, AHunter3 is now armed with both commands and should be able to get to where he needs.

As I remember it, “>” is UNIX and “>>” is DOS, though later versions of DOS do accept “>” as well.

“>” has worked with every version of DOS I’ve used (2.0 (IIRC), 3.3, 4.0, 5.0 and the NT/95/98 DOS window versions - whatever they’re called).

start…run…cmd

/-p, not /-v. Thanks for the tip, Flymaster.

It works! Thank you very much!

(I used ultrafilter’s version; others may work equally well)

I have a FileMaker solution for my girlfriend which calculates the DOS command from an initial folder path she enters, exports it as a batch file, runs it, imports the resultant text file, parses it, and thereby has the names, sizes, modification dates, and modification times of all files in the selected folder.

(All because she has not had good luck with any of TUCOWS’s synchronization programs so I’m writing her one in FileMaker, if you’re curious)

fandango wrote:

The “>” is both unixian and DOSian for “send output to text file.” The “>>” works in DOS, I don’t know about unix, to append to an existing text file.

‘>>’ to append also works in most (all?) unix shells.

To clarify a little:

“command > file.txt” means direct the output from command to file.txt, creating file.txt if it does not exist and overwriting file.txt if it already exists.

“command >> file.txt” means direct the output from command to file.txt, creating file.txt if it does not exist and appending to file.txt if it already exists.

These work in all versions of DOS I’ve used (so all the modern ones) and every *nix shell I’ve used (sh, csh, bash, tsh and ksh) so presumably it works in all of them.

Uhh…tcsh even…sorry, tc :wink:

Guess what my favourite shell is?
You guessed it, I spend the day in tcsh!

Wow. This kicks ass. That clears up several annoyances I’ve been living with for the last few years. Yet one more reason to visit the Straight Dope…