quick little DOS trick
Ed walks into my office and asks if there is a way to get a listing of the files in a directory so he can put it into a spreadsheet. Seeing as how Windows is targeted to the GUI I suggest a quick print screen. He then explains that he wants the listing as data, not as a printout on the screen. I know telling Ed to download cygwin is not going to cut it so I start to tell him there is no hope. But then all the scripting I had to do to admin several Windows labs come back to me and I work out doing this:
dir /OG > listing.txt
which sorts the directories first and then the files and puts it into a text file, listing.txt. The contents of this file can then be placed in excel and quickly parsed using text to column. I know there is probably some sort of perl script or something I could write to do this (I can already see the Java code in my head) but this was beyond Ed and I didn’t have the time to write it for him. So there you have a simple way to turn a directory listing into data. I am sure most of you knew this but it serves as a good reminder to myself.