CompTIA A_ Certification All-In-One Exam Guide, Seventh Edition - Michael Meyers [253]
ATTRIB -R -S -H NTDETECT.COM
You can also automatically apply ATTRIB to matching files in subdirectories by using the /s switch at the end of the statement. For example, if you have lots of files in your My Music folder that you want to hide, but they are neatly organized in many subdirectories, you could readily use ATTRIB to change all of them with a simple command. Change directories from the prompt until you’re at the My Music folder and then type the following:
ATTRIB +H *.MP3 /S
When you press the ENTER key, all your music files in My Music and any My Music subdirectories will become hidden files.
It’s important for you to know that everything you do at the command line affects the same files at the GUI level, so run through these steps.
1. In Windows XP, go to My Computer and create a folder in the root directory of your C: drive called TEST.
2. Copy a couple of files into that folder and then right-click one to see its properties.
3. Open a command-line window and navigate to the C:\TEST folder. Type DIR to see that the contents match what you see in My Computer.
4. From the command line, change the attributes of one or both files. Make one a hidden file, for example, and the other read-only.
5. Now go back to My Computer and access the properties of each file. Any changes?
Wildcards
Visualize having 273 files in one directory. A few of these files have the extension .DOC, but most do not. You are looking only for files with the .DOC extension. Wouldn’t it be nice to type the DIR command so that only the .DOC files come up? You can do this by using wildcards.
A wildcard is one of two special characters—asterisk (*) and question mark (?)—that you can use in place of all or part of a filename, often so that a command-line command will act on more than one file at a time. Wildcards work with all command-line commands that take filenames. A great example is the DIR command. When you execute a plain DIR command, it finds and displays all of the files and folders in the specified directory; however, you can also narrow its search by adding a filename. For example, if you type the command DIR AILOG.TXT while in your root (C:\) directory, you get the following result:
C:\>dir AILOG.TXT
Volume in drive C has no label.
Volume Serial Number is 4C62-1572
Directory of C:\
05/26/2009 11:37 PM 0 AILog.txt
1 File(s) 0 bytes
0 Dir(s) 94,630,195,200 bytes free
If you just want to confirm the presence of a particular file in a particular place, this is very convenient. But suppose you want to see all files with the extension .TXT. In that case you use the * wildcard like this: DIR *.TXT. A good way to think of the * wildcard is “I don’t care.” Replace the part of the filename that you don’t care about with an asterisk (*). The result of DIR *.TXT would look like this:
Volume in drive C has no label.
Volume Serial Number is 4C62-1572
Directory of C:\
05/26/2009 11:37 PM 0 AILog.txt
05/29/2009 05:33 PM 5,776 aoedoppl.txt
05/29/2009 05:33 PM 2,238 aoeWVlog.txt
07/31/2008 10:40 PM 153 systemscandata.txt
4 File(s) 8,167 bytes
0 Dir(s) 94,630,002,688 bytes free
Wildcards also substitute for parts of filenames. This DIR command will find every file that starts with the letter a:
C:\>dir a*.*
Volume in drive C has no label.
Volume Serial Number is 4C62-1572
Directory of C:\
05/26/2009 11:37 PM 0 AILog.txt
05/29/2009 05:33 PM 5,776 aoedoppl.txt
05/29/2009 05:33 PM 2,238 aoeWVlog.txt
3 File(s) 8,014 bytes
0 Dir(s) 94,629,675,008 bytes free
We’ve used wildcards only with the DIR command, but virtually every command that deals with files will take wildcards. Let’s examine the REN and DEL commands and see how they use wildcards.
Renaming Files
To rename files, you use the REN (or RENAME) command, which seems pretty straightforward. To rename the file IMG033.jpg to park.jpg, type the following followed by the ENTER key:
ren img033.jpg park.jpg
“That’s great,” you might be thinking, “but what about using a more complex and descriptive filename, such as Sunny day in the