1 dos 2 directory structure of disks directory structure of disks full path or full file...
TRANSCRIPT
1
DOS 2 DOS 2 Directory structure of disksDirectory structure of disks Full Path or Full file specificationFull Path or Full file specification Creating directories ( Creating directories ( MDMD or or MKDIRMKDIR)) Navigating a directory structure ( Navigating a directory structure ( CDCD or or
CHDIRCHDIR)) Coping files to other directories ( Coping files to other directories ( COPYCOPY ) ) Renaming files ( Renaming files ( RENREN or or RENAMERENAME ) ) Moving files to other directories ( Moving files to other directories ( MOVEMOVE ) ) Deleting files from directories ( Deleting files from directories ( DELDEL or or
ERASEERASE ) ) Deleting directories ( Deleting directories ( RDRD or or RMDIRRMDIR ) ) Listing files in directoriesListing files in directories View, print, and save a directory tree ( View, print, and save a directory tree ( TREETREE ) )
2
DirectoryDirectory Also known as a folder.Also known as a folder.
Acts as a container for files and other Acts as a container for files and other directories.directories.
Is a special file type that contains Is a special file type that contains information about the files and directories information about the files and directories it tracks.it tracks.
Directories provide a means of organizing Directories provide a means of organizing the many files stored on a disk drive.the many files stored on a disk drive.
3
Root DirectoryRoot Directory
The The ROOTROOT directory is the first directory directory is the first directory created. It is created created. It is created AUTOMATICALLYAUTOMATICALLY when the disk is initialized or formatted. when the disk is initialized or formatted. Formatting a disk is the Formatting a disk is the ONLYONLY way to create way to create the the ROOTROOT directory. directory.
It is referred to with a backslash symbol It is referred to with a backslash symbol \\..
A:\>A:\> shows root directory of shows root directory of AA drive drive
Note: The DOS prompt above typically shows you what drive and directory on that drive is the current default ( A:\> ).
4
SubdirectorySubdirectory A subdirectory is a directory contained A subdirectory is a directory contained
within, or “within, or “belowbelow” another directory.” another directory.
This allows the creation of a hierarchy This allows the creation of a hierarchy of directories on a disk drive.of directories on a disk drive.
It is subordinate to another directory It is subordinate to another directory or folder.or folder.
EXAMPLE:EXAMPLE:
A:\Programs\COBOL>_A:\Programs\COBOL>_COBOLCOBOL is a subdirectory of is a subdirectory of ProgramsPrograms
5
DADA DBDB DCDC F1F1 F2F2
Root Directory
DDDD DEDE F3F3 F4F4
DA
F5F5 F6F6 F7F7
DD
F20F20 F21F21 F22F22
DB
F30F30 F31F31
DC
…
F5
…
F6
…
F7
F8F8 F9F9 F10F10
DE
…
F8
…
F9
…
F10
…
F3
…
F4
…
F1
…
F2
…
F20
…
F21
…
F22
…
F30
…
F31
6
Parent DirectoryParent Directory
A directory containing, or “A directory containing, or “aboveabove”, ”, another directory is reffered to as a another directory is reffered to as a parentparent directory. directory.
EXAMPLE:EXAMPLE:
A:\Programs\COBOL>_A:\Programs\COBOL>_
ProgramsPrograms is the is the parentparent directory of directory of COBOLCOBOL
7
FULL PATHFULL PATH
A notation that identifies the exact location A notation that identifies the exact location of a directory or file on disk.of a directory or file on disk.
The The full pathfull path includes the following for a includes the following for a directory or file on a disk:directory or file on a disk:
DriveDrive
Sequence of directory name(s) Sequence of directory name(s) separated by separated by backslahes backslahes ‘\’‘\’..
Name of the directory or fileName of the directory or file
8
FULL PATH EXAMPLESFULL PATH EXAMPLES
EXAMPLE:EXAMPLE: C:\programs\COBOL\Prog1.cobC:\programs\COBOL\Prog1.cob
DriveDrive
C:C: Sequence of directory name(s) Sequence of directory name(s)
((pathpath)) \programs\COBOL\\programs\COBOL\
Name of the directory or fileName of the directory or file Prog1.cobProg1.cob
9
MD - Make DirectoryMD - Make Directory
The command to create or make a The command to create or make a directory is the directory is the MDMDor or MKDIRMKDIR command command
The syntax is :The syntax is :
MD [MD [drivedrive:][:][pathpath]directory name]directory name
10
MD - ExamplesMD - Examples
Create a directory at the root of Create a directory at the root of AA called called ProgramsPrograms
A:\>MD ProgramsA:\>MD Programs
Create a directory at the root of Create a directory at the root of CC called called MyfilesMyfiles
A:\>MD C:\MyfilesA:\>MD C:\Myfiles
What will the following do?What will the following do?
A:\ABC\XYZ>MD MyfilesA:\ABC\XYZ>MD Myfiles
11
MD - SubdirectoriesMD - Subdirectories
This creates a subdirectory called This creates a subdirectory called MemphisMemphis within another directory called within another directory called CITIESCITIES
A:\>MD CITIES\MemphisA:\>MD CITIES\Memphis
This creates a subdirectory called This creates a subdirectory called NashvilleNashville within the within the CITIESCITIES directory directory
A:\>MD CITIES\NashvilleA:\>MD CITIES\Nashville
This creates a subdirectory called This creates a subdirectory called KnoxvilleKnoxville within the within the CITIESCITIES directory directory ((what’s different here?what’s different here?))
A:\CITIES>MD NashvilleA:\CITIES>MD Nashville
12
CD - Change DirectoryCD - Change Directory
The command to change the default The command to change the default directory to a different directory is the directory to a different directory is the CD CD command.command.
The syntax is The syntax is
CD [CD [drivedrive:][:][pathpath]directory name]directory name
13
CD - ExamplesCD - Examples Change to a directory on the Change to a directory on the AA drive called drive called
ProgramsPrograms
A:\>CD ProgramsA:\>CD Programs
Change to a subdirectory named Change to a subdirectory named MemphisMemphis that is under the directory that is under the directory CitiesCities on the on the CC drivedrive
C:\>CD Cities\MemphisC:\>CD Cities\MemphisA:\>CD C:\Cities\Memphis A:\>CD C:\Cities\Memphis ??????
Change to the root directory of the Change to the root directory of the C C drivedrive
C:\Cities\Nashville>CD \C:\Cities\Nashville>CD \
14
MOVEMOVE Syntax:Syntax: MOVE [MOVE [drive:drive:][][pathpath]]filespecfilespec d destinationestination
Examples:Examples:Move a file from one drive to anotherMove a file from one drive to anotherA:\>MOVE letter.docA:\>MOVE letter.doc C:\C:\A:\>MOVE \JKL\RST\letter.docA:\>MOVE \JKL\RST\letter.doc C:\C:\C:\>MOVE A:\JKL\RST\letter.docC:\>MOVE A:\JKL\RST\letter.doc ABC\DEFABC\DEFC:\>MOVE A:\JKL\RST\letter.docC:\>MOVE A:\JKL\RST\letter.doc D:D:\\ABC\DEFABC\DEF
15
MOVE EXAMPLESMOVE EXAMPLES
Move a file named Move a file named resume.docresume.doc into a into a directory called directory called WORKWORK
A:\>MOVE resume.doc WORKA:\>MOVE resume.doc WORK
Use a wildcard to move multiple files into Use a wildcard to move multiple files into a directory called a directory called DATESDATES
A:\:>MOVE 2000*.* DATESA:\:>MOVE 2000*.* DATES
16
COPY file to another directoryCOPY file to another directory
Copy a file named resume.doc at the root Copy a file named resume.doc at the root of A into the directory DOCS on the C of A into the directory DOCS on the C drivedrive
C:\>COPY A:\resume.doc C:\DOCSC:\>COPY A:\resume.doc C:\DOCS
Copy a file named expenses.txt from the Copy a file named expenses.txt from the COST directory into the PAYMENTS COST directory into the PAYMENTS directory on the C drivedirectory on the C drive
A:\>COPY C:\COST\expenses.txt C:\PAYMENTSA:\>COPY C:\COST\expenses.txt C:\PAYMENTS
17
COPY files within a directoryCOPY files within a directory
If the new files are created in the same If the new files are created in the same directory as the old files, the new files directory as the old files, the new files must have a different namemust have a different name
Example:Example:
A:\>COPY oldsales.* newsales.*A:\>COPY oldsales.* newsales.*
18
Copying a fileCopying a file Files can be copiedFiles can be copied
Files can be copied from one disk to anotherFiles can be copied from one disk to another
Files can be copied from one directory to another Files can be copied from one directory to another
When a file is copied, an additional file is createdWhen a file is copied, an additional file is created
The original file is left intactThe original file is left intact
Groups of files can be copied at once by using Groups of files can be copied at once by using wildcardswildcards
19
Syntax for COPYSyntax for COPY
Syntax:Syntax:
COPY COPY sourcesource [ [destinationdestination]]
Example:Example:CA:\>COPY CA:\>COPY classfile.txtclassfile.txt classtwo.txtclasstwo.txt
20
PRACTICE COPYPRACTICE COPY
Type the following:Type the following:
A:>DIR FILE*.*A:>DIR FILE*.*
A:\>COPY A:\>COPY classfile.txt file2.txtclassfile.txt file2.txt
A:\>COPY A:\>COPY file2.txt file3.txtfile2.txt file3.txt
A:\DIR FILE*.*A:\DIR FILE*.*
21
Renaming filesRenaming files
The name of a file can be changedThe name of a file can be changed
When this is done, no additional file When this is done, no additional file is createdis created
The file itself is not movedThe file itself is not moved
22
RENAMING SYNTAXRENAMING SYNTAX
Syntax:Syntax:RENAME [drive:][PATH] RENAME [drive:][PATH] filename1 filename2filename1 filename2
ORORREN [drive:][PATH] REN [drive:][PATH] filename1 filename2filename1 filename2
Examples:Examples:A:\>REN CLASSFILE.TXT NSTIFILE.TXTA:\>REN CLASSFILE.TXT NSTIFILE.TXT
C:\ABC>REN A:\ABC\CLASS1.TXT CLASS2.TXTC:\ABC>REN A:\ABC\CLASS1.TXT CLASS2.TXT
Notice there is no drive or path for Notice there is no drive or path for filename2filename2
23
PRACTICE RENAMEPRACTICE RENAME
Type in the following:Type in the following:
A:\>A:\>DIR DIR file*.*file*.*
A:\>A:\>RENAME RENAME file2.txt file4.txtfile2.txt file4.txt
A:\>A:\>DIR DIR file*.*file*.*
24
RENAMING FILES IN RENAMING FILES IN ANOTHER DIRECTORY OR ANOTHER DIRECTORY OR
DRIVEDRIVEThe name of a file can be changed in a The name of a file can be changed in a directory that is different than the prompt directory that is different than the prompt (the default directory)(the default directory)SyntaxSyntax::
RENAME [drive:][PATH] RENAME [drive:][PATH] filename1 filename2filename1 filename2
OROR REN [drive:][PATH] REN [drive:][PATH] filename1 filename2filename1 filename2
Examples:Examples: C:\>REN A:\DEMO\CLASSFILE.TXT FILEA.TXTC:\>REN A:\DEMO\CLASSFILE.TXT FILEA.TXT C:\ABC>REN A:\DEMO\CLASS1.TXT FILE1.TXT C:\ABC>REN A:\DEMO\CLASS1.TXT FILE1.TXT
25
RENAME with WILDCARDSRENAME with WILDCARDS
More than one file can be renamed by the More than one file can be renamed by the use of wildcards.use of wildcards.
Examples:Examples: C:\>REN 2002*.DAT 2003*.DATC:\>REN 2002*.DAT 2003*.DAT
C:\ABC>REN A:\XYZ\2002*.DAT 2003*.DATC:\ABC>REN A:\XYZ\2002*.DAT 2003*.DAT
26
PRACTICE REN /wildcardsPRACTICE REN /wildcards
Type in the following:Type in the following:
• DIR 200*DIR 200*
• REN 2002* 2003*REN 2002* 2003*
• DIR 200*DIR 200*
27
Deleting filesDeleting files
Files can be deleted from the command promptFiles can be deleted from the command prompt
Syntax:Syntax: DEL DEL filenamefilename
Examples:Examples:A:\DEL A:\DEL NSTIFILE.TXTNSTIFILE.TXT
A:\ABC>DEL C:\XYZ\A:\ABC>DEL C:\XYZ\FILE.TXTFILE.TXT
NOTE:NOTE: Wildcards can be used to delete Wildcards can be used to delete groups of files.groups of files. The following is EXTREMELY The following is EXTREMELY dangerous dangerous A:\DEL *.*A:\DEL *.*
A confirmation message will be A confirmation message will be displayed.displayed.
28
Prompt Switch and the Prompt Switch and the DELETE commandDELETE command
A prompt for verification switch (A prompt for verification switch (/P/P) can ) can be used with the be used with the DELETEDELETE command command
The names of the files to be deleted will The names of the files to be deleted will be displayed and the user can verify be displayed and the user can verify whether to continue with the deletingwhether to continue with the deleting
Example: Example: A:\ABC>DELA:\ABC>DEL NSTIFILE.TXTNSTIFILE.TXT /P/P
29
PRACTICE DELETEPRACTICE DELETE
Type in the following:Type in the following:
COPY COPY classfile.txt newfile1.txtclassfile.txt newfile1.txt COPY COPY classfile.txt newfile2.txtclassfile.txt newfile2.txt DIR DIR *file**file* DEL DEL newfile1.txtnewfile1.txt DIR DIR *file**file* DEL DEL newfile2.txt newfile2.txt /p/p DIR DIR *file**file*
30
TREETREE
The The TREETREE command will display a command will display a directory treedirectory tree
A directory tree is a diagrammatic A directory tree is a diagrammatic representation of the directory structure representation of the directory structure of a hard disk or disketteof a hard disk or diskette
31
SYNTAX OF TREESYNTAX OF TREE
Syntax:Syntax:TREE [TREE [drive:drive:][][pathpath]]
Examples:Examples:A:\>TREEA:\>TREE
A:\>TREE CITIESA:\>TREE CITIES
A:\>TREE C:\ABC\PROGRAMSA:\>TREE C:\ABC\PROGRAMS
32
Navigating a Directory TreeNavigating a Directory Tree
Change the directory Change the directory ANDAND drive in drive in one commandone command
A:\>CD /d c:\doc*\lettersA:\>CD /d c:\doc*\letters
The above command changes the prompt The above command changes the prompt -drive from -drive from AA to to CC-into the documents\letters directory-into the documents\letters directory
33
. . DOT DOT. . DOT DOT
Change to the parent directory of the Change to the parent directory of the current directory by typing in the current directory by typing in the following:following:
A:\ABC\JKL>CD ..A:\ABC\JKL>CD ..
Directory Directory A:\ABCA:\ABC is now current is now current
Type in:Type in: A:\Labs\Lab01>CD ..A:\Labs\Lab01>CD ..
And the prompt changes to:And the prompt changes to: A:\Labs>A:\Labs>
34
TREE-switchesTREE-switches
The The TREETREE command has two switches command has two switches that can be used in display and printthat can be used in display and print
/F/F adds filenames to the directory listadds filenames to the directory list /A/A displays an alternate formatdisplays an alternate format
Example:Example: A:\>TREE /F /AA:\>TREE /F /A
35
Save TREE to a FileSave TREE to a File
To save the listing of To save the listing of TREETREE, use the , use the redirection operator (redirection operator (>>))
ExamplesExamples::A:\>TREE > filelist.txtA:\>TREE > filelist.txt
A:\>TREE /F > filelist.txtA:\>TREE /F > filelist.txt
A:\>TREE /A > filelist.txtA:\>TREE /A > filelist.txt
A:\>TREE /F /A > filelist.txtA:\>TREE /F /A > filelist.txt
36
Print TREEPrint TREE To print the listing of To print the listing of TREETREE, use the , use the
redirection operator (redirection operator (>>))
ExamplesExamples:: A:\>TREE > LPT1A:\>TREE > LPT1
A:\>TREE /F > PRNA:\>TREE /F > PRN
A:\>TREE /A > PRNA:\>TREE /A > PRN
A:\>TREE /F /A > LPT2A:\>TREE /F /A > LPT2
37
XCOPYXCOPY
You can use the You can use the XCOPYXCOPY command to copy all command to copy all the files in the specified directory and the files in the specified directory and (optionally) all its subdirectories to another (optionally) all its subdirectories to another drive and/or directory.drive and/or directory.
XCOPY XCOPY sourcesource [ [destinationdestination] [/S] [/M] [/A]] [/S] [/M] [/A]
Example:Example:
A:\ABCA:\ABC
This copies the contents of the current This copies the contents of the current directory to the root of directory to the root of A:A:..
38
XCOPY /SXCOPY /S
The The /S/S switch enables switch enables XCOPYXCOPY to also copy any to also copy any directories and files beneath the current directories and files beneath the current directory, but it will directory, but it will NOTNOT include empty include empty directories.directories.
Example:Example:
A:\ABC /SA:\ABC /S
This copies the contents of the current directory This copies the contents of the current directory and and ALLALL its subdirectories (if not empty) to the its subdirectories (if not empty) to the root of root of A:A:..
39
XCOPY /MXCOPY /M
The The /M/M switch copies files with the archive switch copies files with the archive attribute attribute onon and then turns it and then turns it offoff..
40
XCOPYXCOPY/A/A
The The /A/A switch copies files with the archive switch copies files with the archive attribute on but does attribute on but does NOTNOT turn it turn it offoff..