Click here to monitor SSC

Jonathan has been working with SQL Server since 1999. He enjoys performance tuning, development and using SQL Server to provide appropriate business solutions. He is the founder and leader of the PASS SQL South West user group , is a moderator at SQL Q + A forum and is on twitter at @fatherjack. He has spoken at SQLBits and SQL in the City, SQL Saturdays and local user groups across the UK and Europe.

Quick Tip: Windows directory file list

Published 30 January 2014 9:51 pm

In a previous version of Windows (circa Windows95 or older) there was a button in the toolbar of it’s equivalent of Windows Explorer that generated a list of files in the open directory, in a text file. Despite searching through I cant locate an image of it or find a demo of it in action but it was pretty useful at the time and I have longed for it to become a feature once again.

Quite often you need to execute something from the command line and that generally means starting cmd.exe and then using a series of CD commands to get to the location of the exe you want to start. That or you have to open Windows Explorer to navigate where you want to go and then copy and right click, paste the path into the CD command to get there a little quicker.

No more.

Open Windows Explorer and navigate to the directory you need.

Press Alt + D.

Your cursor is now in the address bar at the top of the window. Type cmd and press enter.

Hey presto! You now have a command window at the Windows location of your choosing.

Now, getting back to the functionality mentioned at the start of this blog, if you want a list of the files in this directory simply type DIR /B > List.txt and press enter.

You can now type Exit at the command prompt to close cmd.exe, or click the Close Window button.

In Windows Explorer you will now find a file called List.txt that when you open it contains a list of the files in the directory.

While we are staring  at the Tools directory on my laptop this is another great opportunity to remind everyone about the great suite of tools from sysinternals and to recommend using the SyncTools app from Kenny Kerr to keep them all up to date.

Hope this helps!

If you can refer me to a source that names the tool, the version of Windows it was in or even better shows it in action then I would be very impressed, please let me know in the comments.


4 Responses to “Quick Tip: Windows directory file list”

  1. Mo64 says:

    Try – navigate in windows explorer to the folder you need a directory listing of, hold down shift, right click – pick > Open command window here. Then enter your DIR command as above. HTH Mo

  2. Fatherjack says:

    That’s a good alternative too. Thanks for adding it here.

  3. Thomas Rushton says:

    Instead of closing the command window, navigating through Explorer etc to load the text file, try running “start List.txt”.

    (2 characters shorter than “notepad list.txt”…)

Leave a Reply

Blog archive