Chapter 5 — COPY and TYPE Internal Commands

advertisement
Instructor: Prof. Michael P. Harris
Answers to Discussion Questions
Chapter 5
Internal Commands—COPY and TYPE
Chapter 5
Internal Commands — COPY and TYPE
ANSWERS TO DISCUSSION QUESTIONS (p. 235)
1.
Explain the function and purpose of internal commands.
The internal commands allow you to manage or manipulate the files on a disk. Using
internal commands does not create or change data in a file. The internal commands are in
the booting file of CMD.EXE. They are not separate files in WINNT\SYSTEM32
directory. They are always present in memory until the computer is turned off. They do
not need to be loaded from disk every time you want to use them.
2.
Give two reasons for making a copy of a file on the same disk.
1. You may wish to work with a temporary backup file if you are trying something new
with a program. If you do not like the changes, you can always go back to the
original. Note: You cannot have two files with the same name in the same directory,
but can have them in different directories.
2. You may want a backup just in case something goes wrong.
3. You may wish to use the OS to perform housekeeping tasks, i.e., rather than creating
copies in an application package, do it at the OS level.
4. Copy file to a device.
3.
Give the syntax for the COPY command and explain each part of the syntax.
COPY [drive:][path]filename [drive:][path]filename
or conceptually:
COPY source destination
All three portions of the command (COPY, source, and destination) are mandatory.
COPY is the command. Source is what you want copied (original) and destination is
where you want it copied to. Note space between COPY, source, and destination.
Formal syntax variables:
[drive:]
Drive letter where the file is located.
[path]
Subdirectory where the file is located.
filename
Name of the file you wish to copy.
The filename is made up of two parts, filename and extension. If the file
has an extension it is separated from filename by period.
Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line
Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1
Page 1
Instructor: Prof. Michael P. Harris
Answers to Discussion Questions
Chapter 5
Internal Commands—COPY and TYPE
When using OS prior to W95 no spaces are allowed between filename and
file extension.
Windows – may use long filenames that includes spaces – must enclose
entire filename in quotes.
4.
Is a file extension mandatory when naming a file?
No. A file extension is not mandatory when naming a file. Most application programs
allow you to assign the filename but not the file extension. Programs themselves assign
extensions to data files.
Note: You will be naming data files all the time with the program usually assigning the
extension to the data file. However, you will not get an opportunity to name program
files as a programmer assigns these names. Program files commonly have the file
extensions of .COM, .EXE, or .BAT.
5.
What is the maximum number of characters that may be used when naming
a file?
The filename can be no longer than 255 characters, including the file extension. A
period (delimiter) separates the filename from the file extension.
6.
List three characters that cannot be used when naming files.
When naming files it is best to stick to alphanumeric characters. The following characters cannot
be used when naming files: " / \ : ; , | < > * ? + % $
7.
List three examples of legal file names.
Answers will vary.
8.
When would you use a wildcard with the COPY command?
Using wildcards with the COPY command to copy files saves time by reducing the
number of commands that need to be keyed in. It makes it possible to work with a group
of files and it is always faster and easier to work with a group of files than to work with
files one at a time.
9.
What is the purpose and function of the TYPE command? Explain each part
of the syntax diagram.
The TYPE command allows you to display the contents of a file on the screen. File must
be ASCII file for data to be meaningful.
The syntax is: TYPE [drive:][path]filename.
TYPE is the command. What is between square brackets is optional and you need to key
in only what is inside of the square brackets (not the brackets themselves). [Drive:]
represents drive letter, and [path] is the name of the subdirectory where file is located.
The filename is mandatory (if name has an extension it must be included as part of the
filename).
Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line
Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1
Page 2
Instructor: Prof. Michael P. Harris
Answers to Discussion Questions
10.
Chapter 5
Internal Commands—COPY and TYPE
How can you recognize an executable file?
You recognize an executable file by its extension. For example, files with extensions of
.EXE, .COM, or .BAT are executable.
11.
What are ASCII files?
An ASCII file (American Standard Code for Information Interchange) is another name for
a readable text file. It is a code that translates the bits of information into "human"
readable letters.
12.
What is the purpose and function of dummy files?
Dummy files are files that contain no especially useful information. They are used to try
out commands or procedures that you're not sure of without worrying about harming your
"real" program and data files.
13.
Every file on a disk must have a unique name. Yet, when you make a copy
of a file on the same disk in a different subdirectory, it may have the same
file name. Explain.
While each file must have a unique name on the same drive and subdirectory, files that
are on the same disk but in in a different subdirectory may have identical names. The
path makes those file names unique as the full name of the file includes the drive, path
and filename.
14.
Under what circumstances could a user think that the computer has "lost”
its files?
There are many reasons that the user might think that the computer has "lost” its files.
While there is a slight possibility that the computer actually did lose the file due to
hardware or software problems, usually it's the user's fault that s/he cannot find a file.
Files are misplaced because the user gave an instruction that s/he thought meant one
thing, but really meant something else. The most common cause of lost files is when the
file is written into the wrong disk or directory, or simply not saved correctly in the first
place. In these cases the user will probably find the file eventually. The user may also
have deleted the file accidentally in which case the file is permanently lost unless a
backup has been made. You can search for the file on a drive using a special syntax of
the DIR command: DIR \filename.ext /s (Note the root backslash prefix)
15.
Can you use wildcards with the TYPE command? Why or why not?
Yes, the TYPE command supports the use of wildcards. In the same directory, wildcards
are used with common element in files. In multiple directories, must use multiple
wildcards. Earlier versions of TYPE did not support the use of wildcards.
16.
What does the first \ in any command line mean?
The first \ (backslash) in a command occurring at the beginning of a path or just after a
drive letter tells the OS to start at the root directory of the disk.
Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line
Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1
Page 3
Instructor: Prof. Michael P. Harris
Answers to Discussion Questions
17.
Chapter 5
Internal Commands—COPY and TYPE
What does it mean to "overwrite” a file? What are some of the dangers of
overwriting files?
Overwriting of files is the process whereby the contents of the destination file is replaced
with the contents of the source file. The filename remains the same but the contents of the
file have changed.
The main danger of overwriting files is that the contents of the old file are lost as they
have been replaced with the contents of the source file.
18.
Why would you make a copy of a file on the same disk? On another disk?
You would make a copy of a file on the same disk to provide a backup copy of the
original so that you would have a copy of the original and have another copy that you
could edit. You might also want to copy a file to the same disk so that you can change a
small part of the file (like the name on a letter).
You would make additional files and copy them to another disk to prevent loss of data by
possessing an extra copy. It is like a carbon copy of the same data. If you wanted to share
data with another person, you could also copy a file to another disk. If you wanted to
share data files from a home computer at the office, you copy the files to another disk.
19.
What would happen if you tried to copy a file from one disk to another and
the destination disk already had a file with the same name?
Prior to DOS 6.2, if the filename on destination disk was the same as the source file
destination, the file would be overwritten with contents of source file without a warning.
Now, Windows warns you that this will result in an overwrite then you can decide what
you want to do.
20.
How would you combine the contents of two files? Why would you?
To combine the contents of two files (concatenation) use the COPY command and place a
+ sign between the two source files you wish to combine. The syntax would be:
COPY source-file + source-file destination-file
Note: There will be two sources with one destination.
Wildcards can also be used to combine the contents of two or more files but the above
would be the suggested method of combining two files.
The second part of answer will vary. Remember that only text files should be
concatenated.
Several short files easier to work with if combined. Concatenate files to combine multiple
related files. Example: You may have a report typed in one file, the cover page in
another, the bibliography in a third, and you want to put them all together. Remember,
however, that this only works with text files. If you try to concatenate application data
files, it will not work.
Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line
Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1
Page 4
Instructor: Prof. Michael P. Harris
Answers to Discussion Questions
21.
Chapter 5
Internal Commands—COPY and TYPE
What happens to the original files when you combine two or more files?
When combining files with the COPY command, the original files remain unchanged.
22.
What are some of the dangers of concatenating program files or data files?
Program files and data files that programs generate should not be concatenated because
they are binary code. Combining any of these files makes binary code useless. Some
application programs will allow you to merge its own data files but it must be done
within the application program. Data files that are concatenated at the OS level will be
typically unreadable in a program. Concatenate only ASCII files.
23.
What message on the screen informs you that you have concatenated
several files?
The message on the screen informing you that you have concatenated several files is:
1 file(s) copied.
24.
Name two ways that you may print the contents of an ASCII file.
COPY filename PRN
TYPE filename > PRN
However, if you are on a network and do not have a printer assigned, this
command will not work unless you substitute the network printer name, i.e.,
\\server\printer-name
PRINT filenames
25.
Identify two advantages to using the PRINT command to print the contents
of ASCII files.
Print has the advantage of telling you the status of your print job.
You may use wildcards with the PRINT command and each file is printed on a separate
page(s).
Carolyn Z. Gillay, Bette A. Peat, Windows XP Command Line
Franklin, Beedle & Associates ©2003 ISBN: 1-887902-82-1
Page 5
Download