CompTIA A_ Certification All-In-One Exam Guide, Seventh Edition - Michael Meyers [254]
ren img033.jpg Sunny day in the park.jpg
But you’ll get an error message (Figure 15-16). Even the tried-and-true method of seeking help by typing the command followed by /? doesn’t give you the answer.
Figure 15-16 Rename failed me.
You can use more complicated names by putting them in quotation marks. Figure 15-17 shows the same command that failed, but now succeeds because of the quotation marks.
Figure 15-17 Success at last.
Deleting Files
To delete files, you use the DEL (or ERASE) command. DEL and ERASE are identical commands that you can use interchangeably. Deleting files is simple—maybe too simple. Windows users enjoy the luxury of retrieving deleted files from the Recycle Bin on those “Oops, I didn’t mean to delete that” occasions everyone encounters at one time or another. The command line, however, shows no such mercy to the careless user. It has no function equivalent to the Windows Recycle Bin. Once you have erased a file, you can recover it only by using a special recovery utility such as Norton’s UNERASE. Again, the rule here is to check twice and delete once.
To delete a single file, type the DEL command followed by the name of the file to delete. To delete the file AILOG.TXT, for example, type this:
DEL AILOG.TXT
Although nothing appears on the screen to confirm it, the file is now gone. To confirm that the AILOG.TXT file is no longer listed, use the DIR command.
As with the DIR command, you can use wildcards with the DEL and ERASE commands to delete multiple files. For example, to delete all files with the extension .TXT in a directory, you would type this:
DEL *.TXT
To delete all files with the filename CONFIG in a directory, type DEL CONFIG.*. To delete all of the files in a directory, you can use the popular *.* wildcard (often pronounced “star-dot-star”), like this:
DEL *.*
This is one of the few command-line commands that elicits a response. Upon receiving the DEL *.* command, Windows responds with “Are you sure? (Y/N),” to which you respond with a Y or N. Pressing Y erases every file in the directory, so use *.* with care!
Don’t confuse deleting files with deleting directories. DEL deletes files, but it will not remove directories. Use RD to delete directories.
Copying and Moving Files
Being able to copy and move files in a command line is crucial to all technicians. Because of its finicky nature and many options, the COPY command is also rather painful to learn, especially if you’re used to dragging icons in Windows. The following tried-and-true, five-step process makes it easier, but the real secret is to get in front of a C:\ prompt and just copy and move files around until you’re comfortable. Keep in mind that the only difference between copying and moving is whether the original is left behind (COPY) or not (MOVE). Once you’ve learned the COPY command, you’ve also learned the MOVE command!
Mike’s Five-Step COPY/MOVE Process
I’ve been teaching folks how to copy and move files for years by using this handy process. Keep in mind that hundreds of variations on this process exist. As you become more confident with these commands, try doing a COPY /? or MOVE /? at any handy prompt to see the real power of the commands. But first, follow this process step by step:
1. Point the command prompt to the directory containing the files you want to copy or move.
2. Type COPY or MOVE and a space.
3. Type the name (s) of the file(s) to be copied/moved (with or without wildcards) and a space.
4. Type the path of the new location for the files.
5. Press ENTER.
Let’s try an example. The directory C:\STEAM contains the file README.TXT. Copy this file to a USB thumb drive (E:).
1. Type CD\STEAM to point the command prompt to the STEAM directory.
C:\>CD\STEAM
2. Type COPY and a space.
C:\STEAM>COPY
3. Type README.TXT and a space.
C:\STEAM>COPY README.TXT
4. Type E:\.
C:\STEAM>COPY README.TXT E:\
5. Press ENTER.
The entire command and response would look like this:
C:\STEAM>COPY README.TXT E:\