0% found this document useful (0 votes)
126 views56 pages

Ms-Dos: CIT 111 Practical Session 03 by V.P.G. Priyankara

Here are the DIR commands with wildcards to find files starting with the given criteria: DIR C*.* DIR BA*.* DIR DI*.* DIR T*.* DIR T*.txt This will list all files starting with C, starting with BA, starting with DI, starting with T, and starting with T with a .txt extension respectively.

Uploaded by

Lusi Zaira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views56 pages

Ms-Dos: CIT 111 Practical Session 03 by V.P.G. Priyankara

Here are the DIR commands with wildcards to find files starting with the given criteria: DIR C*.* DIR BA*.* DIR DI*.* DIR T*.* DIR T*.txt This will list all files starting with C, starting with BA, starting with DI, starting with T, and starting with T with a .txt extension respectively.

Uploaded by

Lusi Zaira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

MS-DOS

CIT 111 Practical Session 03


By V.P.G. Priyankara
History
• MS-DOS 1.0 was released in August 1981, and was updated
until April 1994 when it was replaced by Windows 95
• All versions of windows still contain some type of DOS, in
windows 95 and 98 you can go to run and type command to
get to DOS prompt, in NT, 2000, and XP you can type CMD
and get DOS.
• In today version, you can type CMD in search bar and select
the CLI or You can use run and run the CMD command in it.
Introduction
The role of DOS is to interpret commands that the user enters
via the keyboard.

These commands allow the following tasks to be executed:


file and folder management
disk upgrades
hardware configuration
memory optimization
program execution
MS Dos
• Microsoft Disk Operating System
• It is system software.
• MS-DOS is a single user single task operating system.
• MS-DOS support CUI (Character User Interface).
• MS-DOS is machine language that links between
application software and hardware and control all
activities.
• Only Keyboard used in MS-DOS.
MS Dos
System Files:
• These files are associated with booting of MS-DOS
• Normally three types of files are maintained in DOS in
order to correctly maintain the boot process.
• These are-
 IO.SYS(BIOS),
 MSDOS.SYS(File and Disk Manager Program)
 COMMAND.COM (Command interpreter)

• The file we interact with DOS is COMMAND.COM


Types of Commands
The commands are of two types :
Internal Commands :
• These are in built commands of MS-DOS i.e. these are
stored in Command interpreter file (COMMAND.COM).
• These commands reside in the memory as long as the
machine is at the system prompt(C:\>) level.
• To use these commands no extra /external file is required.
E.g. DATE, TIME, DIR, VER etc.
Types of Commands
External commands :
These are separate program (.com) files that reside in DOS
directory and when executed behave like commands.
An external command has predefined syntax.
for e.g. HELP, DOSKEY, BACKUP, RESTORE, FORMAT etc
Basic DOS Commands

• General Commands
• Directory Commands
• File Management Commands
General Commands
TIME : sets or displays the system time.

DATE : Sets or displays system date.

TYPE : Displays the contents of at the specified file.

PROMPT : Customizes the DOS command prompt.


Ex.01
• Get the command prompt in your computer. By
pressing Logo key + R (Run Window)
• Then type CMD in the run window and press ok.
• Or search for CMD in your computer and select.
• Enter Time in Command Prompt and Press enter.
• What you can see?
• To terminate Time command, Press Ctrl + C
Ex.02
• Get the command prompt in your computer.
• Enter Date in Command Prompt and Press enter.
• What you can see?
• To terminate date command, Press Ctrl + C
Ex.03
• Get the command prompt in your computer.
• Lets use type command.
• Type command use to display the content of a text file.
• For this exercise, go to your desktop and create a
notepad named Test and Enter following – This is a
example text to test type command.
• Then go to File location and enter file name with Type
command.
Ex.04
• Get the command prompt in your computer.
• Lets use Prompt command.
• Type command use to create new commands or to
view prompts.
• Use these commands
• Prompt $T
• Prompt $D
• Prompt $V
• Type prompt and enter to exit prompt command
DOS General Info
• Filenames and commands are not case sensitive
• You can’t use files that have spaces in their names to
work with DOS
• To terminate a command, Use the CTRL+C or CTRL+
Pause/Break keys.
• The command CLS will clear the screen.
• The command EXIT will close the command prompt
Directory Commands
• DIR : To list all or specific files of any directory on a specified disk.
• MD : To make directory or subdirectory on a specified disk/drive.
• REN : Use this command to rename the folders or files
• CD or CHDIR : Change DOS current working directory to specified
directory on specified disk or to check for the current directory on
the specified or default drive.
• RMDIR or RD : Removes a specified sub-directory only when it is
empty. This command cannot remove root directory (C:\) or
current working directory.
Directory Commands
• TREE : Displays all of the directory paths found on the
specified drive.

• PATH : Sets a sequential search path for the executables


files, if the same are not available in the current directory.

• SUBST : Substitutes a string alias for the pathname and


creates a virtual drive.
Ex.01 -DIR
• Get the Command Prompt (CMD)
• Enter the command DIR
• How many files you can see?
• How many directories you can see?
• DIR stands for Directory
• At the moment you are in C drive (C:\Users\Gihan)
• You can change the directory for E or D drive.
Ex.02 – CD/ CH DIR
• Get the Command Prompt (CMD)
• Enter the command DIR
• Select a folder and type,
CD (Folder name)
• What happened?
• Using CD command you can Change Directory
• How many files you can see?
• How many directories you can see?
Ex.02 – CD/ CH DIR Cont’d
• Now, go back to the earlier folder.
• In order to do it, you need to use CD.. Command
• Use the command and go back.
• Now again go back until there is only C:\ left.
• Try to aces the E:\ Drive (this can be D, F drive
depending on your computer)
• You Can’t use CD.. Command Or CD command for that.
• Just enter the drive letter (E:) and you can enter it.
Ex.03 - MD
• Get the Command Prompt (CMD)
• Enter the command DIR
• Go to the desktop using CD command
• Use MD command and Create a folder named “Test”
MD Test
• Enter the command DIR
• What can you see?
• Is your folder listed there?
Ex.03 – MD Cont’d
• Enter the command DIR
• Go inside the Test folder
• If you go inside, go back once.
• What happened?
• Go to your desktop.
• Can you see the folder you created?
• Open the folder.
• Is there anything?
Ex.04 – REN
• Get the command prompt
• GO inside the desktop using command CD
• Type the DIR, Can you see the Test folder?
• Now, rename the Test folder to “Test123”
REN Test Test123
• Type DIR, can you see the Test123 Folder?
• Again rename it to “Test”
• Then again run the DIR command
Ex.03 - RD
• Get the Command Prompt (CMD)
• Enter the command DIR
• Go to the desktop using CD command
• Use RD command and Delete the folder named “Test”
RD Test
• What happened?
• Use the DIR command again.
Ex.03 – RD Cont’d
• Now, try to use CD command and go to the earlier
folder you created.
• Can you access it?
• Go to your Desktop, Can you see the folder?
• Again, go to command prompt and create the folder
named “Test”
• Now go to the desktop, and open the Test folder
(Without using command prompt)
• Create notepad file inside the folder
Ex.03 – RD Cont’d
• Now go to command prompt again.
• And go to desktop in there using CD command
• Type the DIR command,
• Can you see the folder? Use RD command and Delete it.
• Now try to run DIR command?
• Can you see the Test Folder?
• If the folder has files in it, RD command is not going to
work.
The Help Switch /?
• You can use the help switch with any command. It will
give you the command structure, and the available
switches.
• To get help on command, Type the “Help” keyword and
command after that.
• IT will show you its usages and how to use that
command
Ex.03 Help
• Go to command prompt
• Use the DIR, CD, MD, RD commands with Help switch
• What can you see?
• Can you see the description for each one of them?
• Now use help command for TIME, DATE, TYPE,PROMPT
and see what descriptions you can get.
• Now use TREE, PATH, SUBST commands with help
switch and see what you can get.
MS-DOS Prompt
• The prompt in MS-DOS displays your current directory
• E.g. C:\Users\User

• C:\Users\Documents means you are in documents


directory, and any command you use will apply to the
current directory unless you specify a different one or
move to higher directory like Users in here.
Relative and Absolute path
Alternatively referred to as the file path and full path,
the Absolute path contains the root directory and all
other subdirectories that contain a file or folder.
Absolute path
C:\Windows\calc.exe

Relative path
Relative path starts from the file. Path specifies from
reverse when compared to absolute path.
File Management Commands
DIR (WILDCARD): You can use the * and the ? with DIR
to perform file related tasks.
COPY CON : Use to create new files.

REN/RENAME :Use to rename files

DEL/DELETE : Use to delete files


DIR (WILDCARDS)
Wildcard character will replace a single letter, or word
with a wild character.
• You can use the * and the ? wildcards to search for a
particular file

• The ? character represents ONE CHARACTER, and


• The * character represents MULTIPLE CHARACTERS
DIR (WILDCARDS)
Wildcard character will replace a single letter, or word
with a wild character.
• You can use the * and the ? wildcards to search for a
particular file

• The ? character represents ONE CHARACTER, and


• The * character represents MULTIPLE CHARACTERS
DIR (WILDCARDS) Ex. 1/2
DIR A*.* COMMAND
• First go to your desktop or chosen destination.
• Use the above command.
• What you can see?
• You will see the all files that starting from letter “a” and
having different file type. E.g. Abc.txt
• In this we can see, the letters “bc” and extension “txt”
substituted instead of those *.* in the command
DIR (WILDCARDS) Ex. 1/2
Use the DIR command to find all files starting from
• Letter C
• Letters BA
• Letters DI
• Letter T
• Letter T and extension .txt
DIR (WILDCARDS) Ex. 1/2
DIR *.TXT COMMAND
• First go to your desktop or chosen destination.
• Use the above command.
• What you can see?
• You will see the all files that have the extension of “.txt”.
E.g. Abc.txt/ b.txt/ hello.txt
• In this we can see, each and every file has the extension
of “.txt” but, file names are different.
DIR (WILDCARDS) Ex. 1/2
Try to display All File Names with following Extension
NAMES
• JPG
• MP4
• DOCX
• PPTX
• HTML
DIR (WILDCARDS) Ex. 1/2
DIR ?A*.* COMMAND
First go to your desktop or chosen destination.
• Use the above command.
• What you can see?
• You will see the all files that have the any extension and
having 2nd letter as “A”.
E.g. Back.txt/ Da.html/ Rand.py
Wildcard characters

• Wildcard character will replace a single letter, or word


with a wild character
• * will replace any amount of characters, and ? Will
replace only one.
• Example: copy a:/*.txt c:/ will copy all text files to drive
c:/
• Example 2: copy a:/??.txt c:/ will copy any 2 letter text
file to c:/
Ex.01
Crete a new 02 text file in Desktop (using GUI) and name
it as test.txt and test1.txt
Use the Copy command and copy test.txt file from
Desktop to E:(to any other drive).
Use Following Structure.
COPY C:\Users\(your user name)\Desktop\ test.txt E:\ /v

Did file copy?


Ex.01
Now use the wildcard “?” with the “t” letter to perform
the same task for the test1.txt.
Copy that file to any drive you like.
Use the earlier command format.
Were you able to do it?
Copy Con Command
By this command we can Create a New File.
E:\>COPY CON <NEW FILE NAME>
Process:
• First copy con command creates a new file.
• Then it will ask you to fill in the content for the created
file.
• Then finish with “Ctrl+Z”.
Activity 01
• Open Command Prompt and go to the desktop
directory.
• Use the “Copy Con ”command and create the
“testing.txt” file in the desktop.
• Include this details in the file. ”This is example text
added in a copy con generated file.”
• Finish it with “Ctrl+Z” and use DIR to view it.
• Is the file available there?
Activity 02
• Now use the same command and create following type of
files inside a “Activity” Folder. Use “MD” command to create
the “Activity” folder and go inside the folder, then create the
following files inside of it. Use your own content.
• Wording.doc(x)
• HelloWorld.html
• Present.ppt(x)
• HelloWorld.php
• Sum.xls(x)
Renaming Files
To rename a file, we use the command called “REN” or
"RENAME”.
In order to use this command, first use old name after the
new name.
REN (Old name) (New name)
or
RENAME (Old name) (New name)
Activity 01
• Go to the desktop in your command prompt.
• Create a file named “Subject.txt” inside the desktop
directory.
• Put your subjects as the content inside of that file and
finish it.
• Rename that file into “Degree.txt”.
• Check it in your desktop using DIR command
Removing Files
To Delete a file, we use the command called “DEL” or
“ERASE”.
In order to use this command, use the file name with the
command.
DEL (File name)
or
Erase (File name)
Activity 01
• Use command prompt and go to desktop.
• Use the “DEL” command and delete the “Degree.txt ”
file.
• Use the “DIR” command and confirm if it is deleted or
not.
• Use the “Erase” command and delete the files you
created in using “COPY CON” command.
• Did it work?
Use CMD to search
If you want to find some word or phrase inside the text files in a given
directory, you can use this method.
Use the command “FIND” and type the word you want to find and then
run the command.
Command will output the text files that have same wording inside of them.
FIND “Hello(or any text you want)” *.txt
This will search the contents of all the text files in the current directory and
return a list of all text files that contain the string “Hello”.
This command is extremely useful for searching text files.
Activity 01
• GO to desktop in Command prompt.
• Create a new file named “Myinfo.text” using the copy con command.
• Insert your name, age, address and gender and finish the file with
Ctrl+Z.
• Use the “FIND” command with your name.
• FIND “Your name” *.txt
• See if it is showing “Myinfo.txt” file as the search result?
• Go one step back using “CD..” Command and try the command again
with “na” as the keyword and see how many files will be included in
search result?
Use CMD as Calculator
You can use command prompt as an calculator also.
You only need to do is to use “set /a” and then do the calculation you
wanto to do

Ex. C:\Users\Gihan> Set /a 20+10*30


Answer will be 320.

Try with your own ideas to practice it.


The End
Any Questions?

You might also like