Skip to main content

Filenames (2)

Wild Cards and Literals: Now that you understand filename rules, you should understand the use of two convenient tools: wild cards and literals.

Wild Cards: In the card game poker, a wild card may be any card that a player chooses. Forexample, if deuces are "wild," a player can make three kings by using two kings and a deuce. In DOS, an asterisk (*) character is "wild." The asterisk stands for one or more characters in a filename or extention, beginning with the asterisk position. If only an asterisk is used, it represents the entire filename. A few examples are in order. If you wish to list a directory of all files having the extension COM, you can type the command DIR *.COM and press Enter.

Every filename with the extension COM is listed. If you want to list a directory of every file beginning with the letter W, you can use the command DIR W *.*. Every filename beginning with W and having any extension is listed. Therefore, the wild card lets you select a set of files based upon some common filename characteristic.

Literals: The question mark (?) is used within filenames (and extensions) to represent any character. Forexample, the expression D???????.??? represents all filenames beginning with the character D. If you want to list a directory of filenames having four  or less characters, you can use the command form DIR ????.???. You can also combine literals and wild cards to accomplish the same result by using the command from DIR ????.*.

To display the filenames DISKCOMP.COM and DISKCOPY.COM, you can use DIR DISKCO??.*.

Using Disk Drive Designators With Filenames: Now that you know about filenames, you should also know that you can add the disk drive designator A: through Z:, depending on the number of logical disk drive used by your system and your version of DOS. For example, if  you want to list a directory of all files on disk B beginning with the character D, use DIR B:D*.*.

Noice that the disk drive designator always includes a colon (:). Leaving the disk drive designator off of a filename causes DOS to "lock" on the logged disk drive. That is, if the DOS prompt is A>, disk drive A is logged. If the B> prompt is displayed, disk drive B is logged. Keep in mind that all DOS commands are directed to the logged disk drive unless a different disk drive designator is typed in the command.

You can change logged disk drive by simply typing the drive designator and pressing Enter. To change from A to B, type B: and press Enter. The B> prompt is then displayed, disk drive B is logged. Keep in mind that all DOS commands are directed to the logged disk drive unless a different disk drive designator is typed in the command.

You can change logged disk drives by simiply typing the drive designator and pressing Enter. To change from A to B, type B: and
press Enter. The 3> prompt is then displayed.

Using Directory Names With Filenames: 
Directory (or path) names let you subdivide a disk into separate directories (often called
sub directories or file paths). Every sub directory has a pathname. This gives you the ability to collect similar kinds of information into separate directories, as you would collect files into a file cabinet and into file folders within the file cabinet. You can compare a pathname to the label on a file cabinet drawer or file folder. Information about the creation, naming, and removal of subdirectories is presented later in this section.

Path names use the same naming conventions as filenames. This is true with respect to:
  • legitimate characters
  • length of the pathname
  • optional extension name and length
However, attempting to use the same pathname and filename within the same directory is not permitted by DOS. For clarification, examine a complete filename. Include the disk drive, pathname, and filename designations. A file named MYDATA.DTA on drive C in the file path \MASTER\SLAVE has the complete name C:\MASTER\SLAVELMYDATA.DTA.




Comments

Popular posts from this blog

Path

The PATH command is used to provide access to files located in other directories or on other disks. The PATH command is usually entered as a line in an AUTOEXEC.BAT (or batch) file, which most often contains one or more DOS commands. The AUTOEXEC.BAT file is automatically executed upon system turn-on to run one or more desired programs without the need for user intervention. Other batch  files are executed upon command. When an AUTOEXEC.CAT file is used, each command contained in the file executes as it is encountered. The creation and use of batch files is described in Section 8. To illustrate the PATH command, assume you have a program named GATOR.COM that is located in a sub directory. You are not sure if it is cn disk C or disk A, so you want to search both disks and execute the command when found. To complicate matters, you are not sure if the program is in the SWAMP sub directory or the MUD sub directory. Here is where the PATH command comes to your rescue. To set up a search...

Filenames

It is important to understand DOS file naming conventions and their use. Here, filenames and some special filename "tools" called wild cards and literals are described. What is a File name?   Every program and data file is given a name to differentiate it from other programs and data files. A program is one or more computer instructions collected into a file. A data file is normally a collection of characters (or data) that make up a document, like a letter, or a database, like a collection of accounting transactions or customer records. Descriptive filenames are normally used. For example, if you create and save a letter to Mom, you might give it the filename MOM.LTR. A letter to Dad could be called DAD.LTR. A word processing program file might have the filename WP.COM. Examine these filenames a little closer. First, notice that each filename is meaningful. This is important if you want to know what is in a file by looking at its name. Obscure filenames are of little u...