Working with Files and Directories
Er Abhishek Kumar Agrahari
DOS Tutorial
448 Views
The most fundamental aspects of using computer – |
1. working with files, and |
2. Organizing those files into directories. |
|
|
Files |
A file is simply a collection of information that we store on a disk or diskette.
The normal way to create a file is to run an application.
For example, when we use a word processing application to write a letter, we save the letter by storing it as a file. |
|
In general, each file must have a unique name. However, two files can share the same name provided that they are on different disks, or in different directories. |
|
A file name has two parts: |
• the filename itself and |
• an extension. |
|
In this example: |
RECIPE.DOC |
RECIPE is the filename and DOC is the extension. Note the FULL STOP between the two parts of the name. When a filename has an extension, the two parts of the name are separated by a full stop. |
|
|
Filenames |
We choose filenames with care, as a good name will help us to remember what kind of information is in the file. |
A filename may contain up to eight characters. |
|
For example: |
PDL, README, 4JULY96, MEMO_MAY |
|
|
Exceptions |
The only characters we cannot use in filenames are: |
” / \ [ ] < > + = ; : , ? * { } Spaces are also not permitted. |
Some filenames to avoid |
|
There are some filenames that we should avoid when naming files because our computer reserves them for special uses. |
|
AUX, COM1 or COM2 |
The internal name of a device connected to a Serial Port. |
|
CON |
The internal name of data sent to the keyboard or screen. |
|
LPT1, LPT2, LST or PRN |
The internal names for the printer connected to the Parallel port. |
|
|
|
Extensions |
We use extensions to make our filenames more descriptive. |
For example we could add the extension DOC to every document we write. Then when displaying a list of the files on our disk, we can tell quickly which files contain documents. |
|
NOTE:- |
Some applications add their own unique extensions, these should NOT be altered. If we do the program may not be able to use them. |
An extension may contain up to three characters. |
|
These are all valid extensions: |
A , TXT, 88, B_2 |
|
|
Taking care with extensions |
There are some extensions to which our computer attaches a special meaning. Only add these extensions to a file if we are sure the file performs the correct function: |
|
BAK |
A backup file. When we save a file, the previous version of that file MAY be automatically saved as a backup with a BAK extension. |
|
COM or EXE |
A program or MSDOS /application file |
|
$$$ |
An incorrect or compressed file. |
|
|
|
Directories |
One way of organising the files on our computers Hard disk is to put them in different directories. |
Directories enable us to arrange our files in whatever way we want and get files we need quickly. |
Every disk has one basic directory, called the ROOT directory, which we create automatically when we format the disk. As well as putting files in this directory, we can also create directories inside it. Each subdirectory can hold files, and in turn, further subdirectories. The number of subdirectories on a disk is limited only by the amount of storage space on the disk. |
|
We can visualise a system of directories as an upside-down tree, with the root directory at the top and the subdirectories branching off it. |
|
|
Pathnames |
If we use directories, we must tell our computer where to look for any particular file we want to edit. We do this by specifying the pathname of the file. |
A pathname is a sequence of directory names followed by a filename. Each directory name is separated from the previous one by a backslash ( \ ). |
|
For example the pathname for a file called MEMO.DOC could be :- |
C:\USER\PETER\MEMO.DOC |
|
|