Using ECHO

 <  Day Day Up  >  

Using ECHO

ECHO is used in batch files to control whether the commands and responses in the batch file are displayed ( ECHO ON ) or not displayed ( ECHO OFF ).

Use ECHO with no options to see the current setting for ECHO .

The following batch file demonstrates typical uses for ECHO :

 @ECHO OFF ECHO The following command displays the contents of the current folder DIR/W ECHO The preceding is the listing of the contents of the current folder 
graphics/note_icon.gif

Windows NT/2000/XP permit you to scroll a command-prompt screen forward and backward to see all the contents of the current session. However, Windows 9x/Me do not; a long file can scroll off the screen. Use the MORE command with TYPE in Windows 9x/Me to break a long batch file into multiple pages:

 TYPE MYFILE.TXTMORE 

The symbol is called a pipe (to type it, press Shift and press the backslash key). When you use it in a command like this, it tells the operating system to transfer (pipe) the normal output of the command to the next command listed (in this case, MORE ).


When this batch file is run, the user will see the following:

 The following command displays the contents of the current folder [directory listing] The preceding is the listing of the contents of the current folder 

Using TYPE

The TYPE command is used to display the contents of a file to the screen. It is normally used with text files (including .BAT, Config.sys, and other text-based configuration files).

TYPE MYFILE.TXT displays the contents of myfile.txt to the screen.

Using Folder-Management Commands ( MKDIR , CHDIR , RMDIR )

You can make, change to, or remove folders (directories) with the following commands as shown in Table WCR.2.

Table WCR.2. Folder Management Commands

Command

Abbreviation

Use

Example

MKDIR

MD

Creates a folder (directory)

MKDIR \Backups

Makes the folder Backups one level below the root folder of the current drive

CHDIR

CD

Changes to a new folder

CHDIR \Backups

Changes to the \Backups folder

RMDIR

RD

Removes a folder (if empty)

RMDIR \Backups

Removes the \Backups folder (if empty)

Folders (directories) can be referred to in two ways:

  • Absolute

  • Relative

An absolute path provides the full path to the folder. For example, to change to the folder \Backups\Word from the folder \My Documents on the same drive, you would use the command CHDIR \Backups\Word .

graphics/note_icon.gif

You can't use the CHDIR command to change to a different drive and folder. It only works on the current drive.


A relative path can be used to change to a folder one level below your location. For example, to change to the folder \Backups\Word from the folder \Backups , you would use the command CHDIR Word . No backslash is necessary.

To change to the root folder from any folder, use CHDIR \ . To change to the folder one level higher than your current location, use CHDIR .. .

 <  Day Day Up  >  


Absolute Beginners Guide to A+ Certification. Covers the Hardware and Operating Systems Exam
Absolute Beginners Guide to A+ Certification. Covers the Hardware and Operating Systems Exam
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 310

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net