Quick directory listing using console and… Word
If found an interesting tip on how to get listing of your folder as text, that you can copy to any document or email, without need to manually write all folder and file names. It requires console window and… Word.
Here we go:
- Run console (
cmd
), usecd
command as many times as you need to navigate to “your” directory. - Dump contents of this directory to file, by executing
dir > dir.txt
. - Open
dir.txt
in Notepad or any other text editor. - Select entire text and copy it to clipboard.
- Start Word with a blank document.
- Paste copied text.
- Change font to
Courier
,Courier New
or any other with fixed character length.
You will see a “garbage” similar to this:
Volume in drive C is System
Volume Serial Number is C4D0-D770
Directory of C:\Trash
2010-05-15 20:14 <DIR> .
2010-05-15 20:14 <DIR> ..
2010-05-10 22:28 <DIR> Backup
2010-05-15 20:14 575 dir.txt
2010-05-15 20:40 <DIR> Git
2010-04-10 10:54 <DIR> Phoyo
2010-05-15 18:37 150 850 Running Google Chrome in app mode.jpg
2010-04-16 11:26 <DIR> Windows Ultimate
2 File(s) 151 425 bytes
6 Dir(s) 126 270 541 824 bytes free
Delete first seven and last two lines to get only actual directory listing.
Now, here comes the magic:
- Place your mouse just before first letter of first file or directory name (in above example it would be
Backup
). - Press left Alt key and hold it.
- Select entire area to the left and down, to the last date in last line (in above example that would be
2010-04-16
). - Release left Alt key and hit Delete or Backspace to delete selection.
- Select whole remaining text and copy it into clipboard.
The magic is, that when selecting any text in Word while holding left Alt key, you can create a rectangular selection, that completely ignores characters order and new lines. This allows you to quickly remove unnecessary garbage in your directory dump.
After performing all above step you should end up with something like this:
Backup
dir.txt
Git
Phoyo
Running Google Chrome in app mo
Windows Ultimate
That is — “purified” directory dump.
At first, this solution may sound like time-waste and pointless. But, when you get used to using it and catch some handy perfection you will not be able to perform this operation faster using any other method or way. Especially, if it ever comes to quickly listing directory having hundred of files and folders.