Sometimes you need to create a text or batch file from the command line in Windows. It’s easy to do that — and make sure it’s got the right extension, too. Here’s how.
This tip will work in any version of Windows, even Windows 8 Consumer Preview.
Here’s an easy way to make sure that, when you do create it, it’s got the correct extension.
Click Start>Run>and type: CMD
From the command prompt, type:
echo enteryourtexthereaswhateveryouwantfiletohaveascontents > filename.fileextension
Or create a file that will run the defragmentation engine in Windows as a batch file. To do that, type:
echo defrag c: > defragc.bat
This will put your batch file in the folder where the command line resides — in this case, my Desktop. Note I don’t get a confirmation when it completes successfully.