Please let us know how useful you find this tip by rating it below! If you have a useful Windows tip, timesaver or workaround to share, submit it to our tip contest and you could win a prize!
Microsoft Windows users may sometimes find it convenient to create a batch file on-the fly -- without having to open up an ASCII text editor or creating an ASCII text files using their resident word processor.
A very simple and effective DOS command (perhaps forgotten or unknown to most users) is the "COPY CON" command.
To create the following sample ASCII batch file in the user's root directory (which when executed will display the contents of the user's root directory on the bootable partition of the user's hard drive) do the following:
- Exit Windows by selecting the DOS or command prompt from its menu selection area. Note that when exiting from Windows (all versions), the user will be placed at the C: Windows directory by default.
- To go to the root directory and create the sample ASCII batch file, type the following (without quote marks):
"CD" and press the <ENTER> key.
(The DOS command prompt C:> will appear).
- Next, type "COPY CON LOOK.BAT" and press the <ENTER> key. (LOOK.BAT will be the name of the sample ASCII batch file and to execute this file after it has been created, the user need only type "LOOK" and press the <ENTER> key at the DOS command prompt C: >).
- Next, type "CLS" and press the <ENTER> key.
(This command will clear the monitor screen prior to executing the remainder of the batch file's commands).
- Next, type "ECHO OFF" and press the <ENTER> key.
(This command will prevent the sample batch commands from appearing on the monitor screen as they are executed).
- Next, type "DIR/P" and press the <ENTER> key.
(The "DIR" command displays all of the directories and files contained in the user's root directory C: >).
The "/P" switch limits the display of the root directory's contents to one full screen of data at a time and places the command prompt "Press Any Key To Continue" at the bottom of each single page display.
If the root directory contains a large number of directories and files, the user will be presented with numerous screens of data and can then view each one separately. Then continue on by pressing any key to continue, until all data content has been displayed.
- Lastly, press the "<CTRL> + Z" keys simultaneously.
(This will end creation of the sample ASCII batch file "LOOK.BAT.")
To execute this batch file, the user need only type "LOOK" while at the DOS command prompt C: >. The user will then see all of the directories and files located in the root directory C: of the user's hard drive.
If the user wishes to edit the sample batch file "LOOK.BAT" just created, the user may utilize the DOS "EDIT.COM" program (in all Windows versions) by typing "EDIT LOOK.BAT" and pressing the <ENTER> key. The three command lines, "CLS, ECHO OFF, and DIR/P" will be presented on screen.
Clicking the left mouse button on the FILE portion of the uppermost menu will allow the user to select "EXIT" from the pull-down menu, thus returning the user to the DOS command prompt C: >.
NOTE: Users are advised not to use conventional word processors (without ASCII file creation/editing features) because "high order ASCII characters or machine language" inserted by such word processors in a batch file will render it inoperative.