This is a quick tutorial on how to capture command line output to file in Windows. This is useful for a variety of reasons, but it really comes in handy when you are trying to fix a problem in your computer, and you need to send data to someone else to help you out.
This is what you normally would do: You would open the Command Prompt and type the command and wait for the output; right-click in the window and select mark, select the content that you need. Create a new text file, paste the output result, and finally save the file. This process is about 7 steps!
Capturing commands output
There is an easier way to do this with a command line switch; it will reduce from 7 steps in to 2.
1. Open Windows Command Prompt or cmd.
2. Type the command you wish like this:
and press Enter. The (>) symbol is what makes all possible, in conjunction with the destination file, to pour whatever is the outcome of the command to a file.
You won’t see the output result in the command prompt window, but you’ll see its content when you open the file. If you need to append results to the contents of an existing text file use the following symbols >>
Not only you can use txt file extension but you can also use the old Microsoft Office extensions, like doc or xls.
- C:\”Folderlocation”> dir /b >c:\your_output_file_name.csv
Or if you need to create a list of specific type of file, use this command:
- C:\”Folderlocation”> dir *.doc/b >C:\ your_output_file_name.csv
(*) represents any name and (.doc) the kind of file that you want a list from and (/b) uses bare format (no heading information or summary).
Using CSV format will generate an excel type file and every entry will be organized in cells.
All these should work in Windows XP, Windows Vista, Windows 7; etc.
That is all there is to it!