# DOS command\>make text file listing of files in dir

**URL:** <https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232>\
**Category:** Factual Questions\
**Created:** [October 9, 2001, 1:52am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232 "2001-10-09T01:52:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)\
**Post date:** [October 9, 2001, 1:52am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/1 "2001-10-09T01:52:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ringo](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@Ringo](https://boards.straightdope.com/u/Ringo)\
**Post date:** [October 9, 2001, 1:57am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/2 "2001-10-09T01:57:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ringo](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@Ringo](https://boards.straightdope.com/u/Ringo)\
**Post date:** [October 9, 2001, 1:59am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/3 "2001-10-09T01:59:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Una\_Persson](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/una_persson/32/346_2.png) [@Una\_Persson](https://boards.straightdope.com/u/Una_Persson)\
**Post date:** [October 9, 2001, 2:00am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/4 "2001-10-09T02:00:34Z")

</div>

> [@](#):
>
> _Originally posted by beatle \*  
> dir c:\folder\*. /s \> C:\windows\desktop\list.txt_

---

<div class="post-metadata">

**Author:** ![Una\_Persson](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/una_persson/32/346_2.png) [@Una\_Persson](https://boards.straightdope.com/u/Una_Persson)\
**Post date:** [October 9, 2001, 2:01am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/5 "2001-10-09T02:01:37Z")

</div>

> [@](#):
>
> Slight correction for type

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

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [October 9, 2001, 2:02am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/6 "2001-10-09T02:02:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ringo](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@Ringo](https://boards.straightdope.com/u/Ringo)\
**Post date:** [October 9, 2001, 2:09am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/7 "2001-10-09T02:09:55Z")

</div>

**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.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [October 9, 2001, 2:15am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/8 "2001-10-09T02:15:56Z")

</div>

**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.

---

<div class="post-metadata">

**Author:** ![Ringo](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@Ringo](https://boards.straightdope.com/u/Ringo)\
**Post date:** [October 9, 2001, 2:23am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/9 "2001-10-09T02:23:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fandango](https://avatars.discourse-cdn.com/v4/letter/f/b5ac83/32.png) [@fandango](https://boards.straightdope.com/u/fandango)\
**Post date:** [October 9, 2001, 2:41am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/10 "2001-10-09T02:41:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ringo](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@Ringo](https://boards.straightdope.com/u/Ringo)\
**Post date:** [October 9, 2001, 2:45am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/11 "2001-10-09T02:45:31Z")

</div>

“\>” 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).

---

<div class="post-metadata">

**Author:** ![Flymaster](https://avatars.discourse-cdn.com/v4/letter/f/c4cdca/32.png) [@Flymaster](https://boards.straightdope.com/u/Flymaster)\
**Post date:** [October 9, 2001, 3:21am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/12 "2001-10-09T03:21:06Z")

</div>

> [@](#):
>
> \*Originally posted by ultrafilter \*  
> \*\ ***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. \*\*

start…run…cmd

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [October 9, 2001, 3:28am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/13 "2001-10-09T03:28:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)\
**Post date:** [October 9, 2001, 5:13am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/14 "2001-10-09T05:13:24Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![CurtC](https://avatars.discourse-cdn.com/v4/letter/c/ce73a5/32.png) [@CurtC](https://boards.straightdope.com/u/CurtC)\
**Post date:** [October 9, 2001, 5:20am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/15 "2001-10-09T05:20:46Z")

</div>

fandango wrote:

> [@](#):
>
> As I remember it, “\>” is UNIX and “\>\>” is DOS, though later versions of DOS do accept “\>” as well.

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.

---

<div class="post-metadata">

**Author:** ![Popup](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@Popup](https://boards.straightdope.com/u/Popup)\
**Post date:** [October 9, 2001, 6:48am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/16 "2001-10-09T06:48:25Z")

</div>

> [@](#):
>
> \*Originally posted by CurtC \*  
> \*\*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.

---

<div class="post-metadata">

**Author:** ![dylan\_73](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@dylan\_73](https://boards.straightdope.com/u/dylan_73)\
**Post date:** [October 9, 2001, 9:43am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/17 "2001-10-09T09:43:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dylan\_73](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@dylan\_73](https://boards.straightdope.com/u/dylan_73)\
**Post date:** [October 9, 2001, 9:47am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/18 "2001-10-09T09:47:06Z")

</div>

> [@](#):
>
> \*Originally posted by dylan\_73 \*  
> \***nix shell I’ve used (sh, csh, bash, tsh…**

Uhh… **tc** sh even…sorry, **tc** 😉

---

<div class="post-metadata">

**Author:** ![Popup](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@Popup](https://boards.straightdope.com/u/Popup)\
**Post date:** [October 9, 2001, 10:08am UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/19 "2001-10-09T10:08:27Z")

</div>

> [@](#):
>
> \*Originally posted by dylan\_73 \*  
> \*\*Uhh… **tc** sh even…sorry, **tc** 😉 \*\*

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

---

<div class="post-metadata">

**Author:** ![slortar](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@slortar](https://boards.straightdope.com/u/slortar)\
**Post date:** [October 9, 2001, 2:17pm UTC](https://boards.straightdope.com/t/dos-command-make-text-file-listing-of-files-in-dir/86232/20 "2001-10-09T14:17:00Z")

</div>

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…
