MS Dos
MS Dos
History
Introduction
File Manipulation
1
8/23/2017
Directory Manipulation
Basic Structure
■ 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.
2
8/23/2017
3
8/23/2017
■ 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
■ 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 more 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
■ DEL will delete a file or an empty directory from the drive ■ EDIT will open a text file
5
8/23/2017
■ REN will rename the file ■ MD is used to make 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
■ 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, read-
only, archive or system file.
■ In MS-DOS you can view/change attributes with the attrib
command.
■ Example: attrib +r file.txt will make the file read-only.
7
8/23/2017
■ Similarly, the TIME command returns the Now run the following command: attrib -h -r -s -a *.*.
current time from the system. This will remove the attributes hidden, archive,
system from all the files.
F:\>edit test.txt
F:\>edit test.txt
F:\>edit 123.docx
F:\>dir>1234.txt
8
8/23/2017
Batch file
9
8/23/2017
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.
10
8/23/2017
11