CCP105

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 17

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH

Name : M.Bhagya Lakshmi,


Designation : Lecturer in CCP,
Institution : GMR Polytechnic, Gajwel
Branch : DCCP
Year/Semester : First Year
Subject name : Computer Fundamentals.
Subject Code : CCP-105
Major Topic : DOS Operating System
Sub –Topic :Modes of processing
Duration : 50 min.
Teaching Aids : PPT
CCP105.34 1
OBJECTIVES:

On completion of this period , you will be able to :

 Create and use some batch files

CCP105.34 2
RECAP:

 BATCH FILES
 CREATION OF BATCH FILES
 EXECUTING THE BATCH FILES

CCP105.34 3
SOME OF THE EXAMPLES FOR
BATCH PROCESSING.

Creation of a batch file


c:\>Copy con TESTI. BAT
cls
dir
date
time
^z
Output: This batch file will execute all the commands in the
sequence and come back to the system
Prompt (C:\>)

CCP105.34 4
BATCH FILE TO DELETE A FILE

C:\>copy con TEST2. BAT


del lotus.Text
^z

Output : This batch file will delete the file named lotus.txt. If
the file is not available, it will display an
error message ‘File not Found’.

CCP105.34 5
BATCH FILE TO DELETE A FILE…. CONTD

 But, the above file can be used only once as


by the time you execute the batch file for the second
time, lotus.txt is already deleted and the message
‘Files not Found’ will be displayed.

 In order to overcome this problem and in order to use


a single batch file many times, ‘PARAMETERS’ are
introduced.

 Parameters can be passed in a batch file using ‘%’


symbol like %1. %2. %3.etc.

CCP105.34 6
EXAMPLE

Batch file to delete a file by passing a parameter

C:\>Copy con TEST3. BAT


Del %1
^z
Execution Procedure:
When a parameter is passed in the batch file, we can’t
execute the batch file by simply typing it’s name at the
system prompt. We ‘ll have to provide value for
parameter too.
CCP105.34 7
EXAMPLE:

C:\>TEST3 rose. txt.

Here %1 will be replaced by rose.txt.

Output : it will delete the file rose.txt

The advantage of sending parameters is that the same


batch file can be used to delete any file.

CCP105.34 8
EXAMPLE:

C:\> TEXT3 tiger.exe

Output : it will delete the file tiger.exe

Note : it is advised that parameters should be always in


ascending order starting from %1 %2 %3 %4 ….upto
%9.

CCP105.34 9
BATCH FILE TO RENAME USING
PARAMETERS

C : \> copy con TEXT4.BAT


Ren %1 %2
^Z

Executing procedure :

C : \ > TEST4 apple.dat coke

Output : it will rename the file apple.dat with coke

CCP105.34 10
Note :
Here, In all the above cases, you will
observe that the batch file will read every
statement and displays the statement at the
system prompt and then executes it.

CCP105.34 11
Contd..,
Note :

To overcome this problem, the


following statement can be included
in the batch in the very first line.

ECHO OFF

CCP105.34 12
SUMMARY:

 Creation of Batch Files

 Examples for BATCH PROCESSING

CCP105.34 13
QUIZ

Parameters can be passed in a batch file using ____ symbol


a) $
b) %
c) &
d) @

CCP105.34 14
ASSIGNMENT
1. Create a batch file to show the contents of two or more
files on screen

CCP105.34 15
FREQUENTLY ASKED QUESTIONS

1. What is a batch file? Create a batch file using


parameters.

CCP105.34 16
CCP105.34 17

You might also like