List of Filenames from a Directory in Text Format

June 20, 2007 at 2:22 pm 24 comments

There have been occassions where I want a list of filenames in a directory, sometimes to use as a checklist as I worked with the files.  I remember a few times I actually took screenshots of a Windows Explorer window in various stages of scrolling and printed those out.  I also remember a few times where I handwrote the names on a sheet of paper.

That was well before I was taught much better ways by kind Craig Highsmith of Pennsylvania.  One method he demonstrated was through SnagIt.  But his DOS prompt method is more readily accessible:

1) Drop to DOS prompt (Start->Run; cmd)
2) Change to the directory you wish to get a text-based file listing (via cd commands)
3) Run “dir *.* /b >>fileListing.txt

/b puts the directory listing into “Bare Mode”– it will only show the filenames and you won’t see dates modified and file sizes and all that jazz.  The >>fileListing.txt tells it to place the results in a text file named, you’ve guessed it, “fileListing.txt”  That file will be in the same directory you are querying.  You open it up and howdy ho, there are the file names in text format.  You can paste them in Excel, print them out, email them or whatever suits you.

It’s a much more flexible technique than my home-grown screenshot approach!  😉

Entry filed under: DOS.

MAILTO: Link from a VB6 App Fun with Brussel Sprouts

24 Comments Add your own

  • 1. Clint  |  June 20, 2007 at 3:30 pm

    1980s techniques work best for things that were possible in the 1980s!

    People would do that using SnagIT?!?!?!?!? That’s like having to buy a graphing calculator because your forgot your multiplication tables!!

    /b /s is even better because it gives the full path as well as gets all subdirectories…

    Reply
  • 2. geekhiker  |  June 20, 2007 at 11:56 pm

    Isn’t it funny when things in Windows make you miss DOS? You have to wonder who the brilliant mind at Microsoft was who thought “nah, nobody will ever want to print a file listing…”

    Reply
  • 3. Scott  |  June 21, 2007 at 6:01 am

    In the DOS days I would just send the list straight to the printer using something like “DIR /b > LPT1:” You can still do it today, but you usually need to map your network printer to LPT1 using something like “NET USE LPT1: \\SERVER\PRINTER”

    Reply
  • 4. Clint  |  June 21, 2007 at 7:43 am

    GeekHiker, your comment is invalid. There is nothing stopping you from doing what Vicky describes under windows. They never took the command-line away, and it’s still there now, and still does exactly the same thing.

    Reply
  • 5. tgaw  |  June 21, 2007 at 8:03 am

    I think his comment is still valid. You still have to drop to DOS to get the file listing.

    Reply
  • 6. geekhiker  |  June 21, 2007 at 8:05 am

    Clint – Very true. But wouldn’t it be nice to, in an explorer window, simply be able to go File->Print Directory Listing? Remember, most average users these days are terrified of the DOS prompt…

    Reply
  • 7. Clint  |  June 21, 2007 at 8:41 am

    TGAW:
    While you could say that you technically t drop to dos to get the file listing, DOS is an operating system. Windows is not DOS. You drop to the command-line. Every operating system, even the MAC, has a command-line. “Missing DOS” would, to me, imply booting to a DOS operating system, with no GUI, no 32-bit support, no fancy text editors with resizeable fonts and mouse control, etc.

    I don’t miss that. Acting like you need to go back to those days to get a file listing is not technically accurate to me.

    GEEKHIKER (I thought you were random and would never see my response, heh):

    That would be nice.

    Or, if you “cut” several selected files, and “paste”ed into notepad, that it would just paste the filenames.

    But users being terrified of the command-line is their own damn problem. If they would rather spend 15 hours earning enough disposable income to pay $100 for SnagIt (I’m making up numbers here), than 5 minutes looking it up on the internet and doing it in the way that has worked since 1980 — then SnagIT can have their money, and I will laugh.

    Reply
  • 8. Clint  |  June 21, 2007 at 12:35 pm

    That “NET USE LPT1: \\SERVER\PRINTER” tip is hot!

    Reply
  • 9. Eduardo Arancibia  |  March 21, 2008 at 9:13 am

    I had a shareware to do this on my PC but I lost it, so looking on Google for how to get a list of filenames I found this emtry. It works fine! I recall the great KISS (Keep It Simple $ Stupid).
    Thanks a lot.
    P.S. I already have an URL but I am looking for an easy way to write my web page (I know how to write HTML).

    Reply
  • 10. Louise  |  June 22, 2009 at 9:03 pm

    Thanks! This saved me about 45 minutes of transcribing and then the inevitable 20 min of tracking down which transcribed file name had the typo

    Reply
  • 11. rajesh  |  September 11, 2009 at 3:38 pm

    it saved my day, i thought of writing a small program in C# to do this 🙂

    Reply
  • 12. Andrew  |  November 17, 2009 at 10:59 pm

    Thank you for the tip. It worked. I agree with the people who said that this feature was missing from Windows. Technically, it might not be missing. In real life, getting a list of file names IS missing from windows.

    Reply
  • 13. Osmooms  |  May 20, 2010 at 4:11 am

    Wouldn’t it be great if this could be made a shell extension!!!

    Reply
  • 14. Hroneygoatweed  |  October 3, 2010 at 2:51 am

    The reality is that erectile dysfunction is common with an estimated 1 in 10 men experiencing it at some stage of their lives. Furthermore, many cases can be treated or improved.

    Reply
  • 15. marc  |  January 2, 2011 at 10:26 am

    For those of you who would like to do similar things without opening the dos box. save this as directoryList.bat (or whatever you want as long as it is a .bat file. save to sendto directory , then you can right click on any folder , choose send to, hey presto you are done.

    from…

    http://renegademinds.com/TipsTricks/Dumpfileanddirectoryliststotextfiles/tabid/56/Default.aspx

    @echo Directory and sub-directory file listing dump by RenegadeMinds.com.
    @echo Visit http://Renegademinds.com for more Windows tips and tricks
    @echo and free software applications.
    @echo ==================================================================
    @echo ==================================================================
    @echo Save this file as getDirList.bat in your SendTo directory.
    @echo SendTo is under Documents and Settings in each user’s directory.
    @echo Right-click on any directory in Windows Explorer and choose
    @echo Send To – getDirList.bat
    @echo ==================================================================
    @echo ==================================================================
    @echo Dumping directory listing to c:\dirListing.txt
    @echo (This may take some time for large directory trees.)
    @REM the /A switch lists all hidden and system files as well.
    @REM the /S switch lists all subdirectories and their contents.
    @dir %1 /A /S > c:\dirListing.txt
    @echo Opening c:\dirListing.txt in Notepad (Close notepad to delete file)
    @notepad c:\dirListing.txt
    @echo Deleting c:\dirListing.txt
    @del c:\dirListing.txt
    @pause

    Reply
  • 16. James  |  June 15, 2011 at 4:29 am

    On a Mac, just select the files, and then goto the text editor and paste. Voila – a list of filenames.

    Reply
  • 17. 01 Systems  |  June 23, 2011 at 7:44 am

    Hi Vicky!

    Thanks for your post, really helped me get a list of filenames for use in a spreadsheet.

    >> Subscribed 🙂

    Kind Regards

    Reply
  • 18. sal  |  August 5, 2011 at 5:47 pm

    I am running windows7 64 bit and I can’t get this to work. The text file ends up in my documents folder but it is always blank. Any idea why I am getting a blank file?

    Reply
  • 19. Emamul Khankhan  |  August 19, 2011 at 1:52 am

    good one…

    Reply
  • 20. PlanetMaster  |  November 27, 2011 at 3:02 pm

    Thanks, I needed that and very simple.

    Reply
  • 21. Thanks!  |  September 13, 2012 at 10:12 am

    Please know that 4 years after you wrote this post, it’s still relevant and useful. Thanks!

    Reply
  • 22. Marco  |  October 12, 2012 at 7:55 am

    You saved my day!

    Reply
  • 23. Gavo  |  January 7, 2013 at 5:19 pm

    For newer versions of Windows 7 and I have done this on Windows 8 too – especially with a device that might be corporate managed – to right click on the CMD option and “run as admin”

    Reply
  • 24. Setec Astrology  |  July 22, 2013 at 4:40 pm

    Still coming in useful…

    Reply

Leave a reply to tgaw Cancel reply

Trackback this post  |  Subscribe to the comments via RSS Feed


Flickr Photos

3D Printed Products