Quick viewing(Text Mode)

Basic Ms-Dos

Basic Ms-Dos

8/23/2017

History

■ MS-DOS 1.0 was released in August 1981, and was updated until April 1994 when it BASIC MS-DOS was replaced by Windows 95 ■ All versions of windows still contain some of DOS, in windows 95 and 98 you can go to run and type to get to DOS prompt, in NT, 2000, and XP you can type ~ Dharma Raj Poudel CMD and get DOS.

Introduction File Manipulation

The role of DOS is to interpret commands that

the user enters via the keyboard. - Lists files and subdirectories • Wildcard Characters ? * EDIT - creates a new file or modifies an existing file These commands allow the following tasks to be - copies a file or a group of files executed: XCOPY - copies all files in a (and its subdirectories) ∑ file and folder management or ERASE - deletes a file or a group of files UNDELETE - undeletes files ∑ disk upgrades COPY (or XCOPY) plus DEL - moves files ∑ hardware configuration DOSKEY - recalls commands ∑ memory optimization RENAME or - renames files TYPE - displays text files ∑ program execution PRINT - prints a COPY - used to create a file ATTRIB - sets file properties FC - compares two files

1 8/23/2017

Directory Manipulation Basic Structure

MD or - creates a directory ■ Most DOS commands use the same or CHDIR - changes

PROMPT - changes the command prompt ■ Command Source Destination /Switch

TREE - displays the directory structure ■ The switch will give options to the command

RD or - removes a directory ■ Example COPY A:\file.txt c:\ /v ■ /v will verify if the file copied correctly REN - Renaming directories

PATH - creates a search

The Switch /? MS-DOS Prompt

■ You can use the help switch with any command. It will give ■ The prompt in MS-DOS displays your current directory you the command structure, and the availible switches.

■ C:\\commands> means you are in that directory, and any command you use will apply to the current directory unless you specify a different one.

2 8/23/2017

Relative and Absolute path DOS Naming

Alternatively referred to as the file path and full path , ■ Characters like * + = | \ [ ] : ; “ < the absolute path contains the root directory and all > , ? / cannot be used in DOS other subdirectories that contain a file or folder. names. absolute path C:\Windows\calc.exe

Windows non absolute path (relative path) calc.exe

Wildcard characters Basic Commands CD

■ Wildcard character will a single letter, ■ CD- Change directory or word with a wild character ■ You use this command when you want to change the directory. ■ * will replace any amput of characters, and ? Will replace one. ■ Example: CD C:\DOS will bring you to the dos folder ■ Example: copy a:/*.txt c:/ will copy all text files to drive c:/ ■ Example 2: copy a:/?????.txt c:/ will copy any 5 letter text file to c:/

3 8/23/2017

Basic Commands CD.. And Basic Commands CD\

■ CD.. - brings you to the previous directory. ■ CLS Will clear the contents of the screen ■ Example: if you are in C:\DOS\FOLDER CD.. Will bring you to C:\DOS

Basic Commands DIR Basic Commands COPY

■ DIR will display the contents of the folder ■ COPY will copy the file from one location to another ■ Example COPY A:\file.txt c:\ will copy the file from a:\ to c:\

4 8/23/2017

Basic Command XCOPY Basic Commands

■ XCOPY can move files, directories, and whole drives from one ■ MOVE will move the file or directory from one location to location to another, It is powerful then the copy another command, and has a lot of switches.

■ Example: MOVE a:\file.txt c:\file.txt will move the file to the c:\ drive

Basic Command DEL Basic Command EDIT

■ DEL will delete a file or an empty directory from the drive ■ EDIT will a text file

5 8/23/2017

Basic Commands REN Basic Commands MD/RD

■ REN will rename the file ■ MD is used to a directory (folder) in MS-DOS. ■ Example : REN file.txt myfile.txt will rename the file.txt to ■ Example: MD myfolder will make a folder called myfolder in myfile.txt current directory ■ RD is used for remove directory

Deleting folders and sub folders Basic Command

■ TREE shows you all of the folders and files in current directory like explorer in windows.

6 8/23/2017

Attributes The MORE Command

■ Attributes are the properties of a file such as hidden, - only, archive or . ■ In MS-DOS you can view/change attributes with the command. ■ Example: attrib +r file.txt will make the file read-only.

The PRINT Command The PROMPT Command

■ The PRINTPRINTPRINT Command in MS DOS is used to the text files ■ The PROMPT is used to configure a DOS prompt into our linking ■ Syntax : – PRINTPRINTPRINT ■ Syntax : ■ E.g. – C:\ PROMPT Promptname – PRINTPRINTPRINT File1.txt ■ E.g. – PROMPT NCIT

Now, the Prompt will be as NCIT

7 8/23/2017

Removing unwanted Files

Checking the Date/Time command line. Go to Run –> cmd. This should open the command ■ For checking the date from the system in MS prompt. DOS, we use the DATEDATEDATE command. It returns the current system date. Type g:\ where g is the USB drive letter. ■ Similarly, the TIMETIMETIME command returns the Now run the following command: attrib -h -r -s -a *.*. current from the system. This will remove the attributes hidden, archive, system from all the files.

■ Syntax : Type del autorun.inf. This will delete the autorun.inf – C:\>DATEDATEDATE file. ■ E.g. C:\>DATEDATEDATE

F:\>edit test.txt

F:\>edit test.txt

F:\>copy con 123.docx my name is indika rathninda^Z 1 file(s) copied.

F:\>edit 123.docx

F:\>dir>1234.txt

8 8/23/2017

Batch file

DOS, OS/2, and Windows, a batch file is a

type of script file , a text file containing a

series of commands to be executed by the

command line interpreter. A batch file may

contain any command the interpreter accepts

interactively the command prompt.

9 8/23/2017

The Old New Thing Concatenating Files Together in MS-DOS

Say you have two files (or twenty) named textfile1.txt and The command processor CMD.EXE comes with a mini- textfile2.txt. calculator that can perform simple arithmetic on 32-bit You want to create a new text file that combines the two. signed integers: While you could open each file up in your favorite editor C:\>set /a 2+2 4 and copy and paste the text, this is time consuming and C:\>set /a 2*(9/2) 8 error prone. A much easier way to accomplish this task is C:\>set /a (2*9)/2 9 to use the copy command: C:\>set /a "31>>2" 7 Note that we had to quote the shift operator since it >copy *.txt result.txt would otherwise be misinterpreted as a "redirect stdout and append" operator. This will take all the files with the extension .txt and create a new text file called result.txt out of all of them. For more information, type set /? at the command prompt.

Finding Text Inside Files in MS-DOS

Lets assume I have a group of text files and I need to out quickly which one contains the string "Test" inside it. You can quickly accomplish this using the 'find' command like so: >find "Test" *.txt This will search the contents of all the text files in the current directory and return a list of all of them that contain the string "Test". This command is extremely useful for searching text files.

10 8/23/2017

Removing All Short Cuts

Navigate to you pen drive/ flash drive by typing drive letter. Type “del *.lnk “and hit Enter on your keyboard. Now type “attrib -s -r -h *.* /s /d /l” and hit enter.

11