How to create a text file of a directory

The problem:

A friend and colleague needed to transfer the details of a file's contents. As there were too many items and didn't have spare time to sit and type them out, she was preparing to send screen-captures.

Unfortunately, no matter which way she sorted things, private company files would be in the view (or should I say views, as there were three screen-captures in total), also revealing some files that maybe she shouldn't - her idea was to get me to 'Photoshop' the files out and merge the three images in to one.

The solution:

I first used this technique a good-few-years-ago and have taken it for granted that everyone knew how to do it, but the quick and easy process almost blew the mind of my non-techy colleague. So, without further delay, here it is.

Using my genealogy file to illustrate:

Libraries >> Documents >> GENEALOGY

By holding down the Shift key and right-clicking on my main genealogy directory, I can select ‘Open command window here’ or click the 'w' key (as illustrated, you will note the 'w' of command window is underlined).

Click on the main directory. Shift + right-click > w

With this folder now selected, I have the choice of how much information I wish to capture:

The Command Prompt is now open in the main directory

The basic command of dir >[name of file].txt

dir >geno.txt

will output

geno.txt

If you only wish to capture file names, without all the additional information, try dir /b >[name of file].txt

dir /b >geno_2.txt

And if you want to go deeper, try dir /s >[name of file].txt

dir /s >geno_3.txt

Which you can combine to capture only file names dir /b /s >[name of file].txt will do the trick.

dir /b /s >geno_4.txt

Taking this a little further, as the text files are producing delimited data, it's any easy process to import into Microsoft Excel.

Conclusion:

My colleague is now very grateful for asking me (even if I did laugh at her at first).


Further reading:

Command-Line Reference: Dir