What is a Wild card ::
The wildcards are nothing but a symbolic representation of one or more characters. which is usually used within the MS-dos commands. They are usually used in dir,copy,del,xcopy etc.
There are basically two types of wildcards.
- Asterisk (*)
- Question Mark (?)
Asterisk is used for one or more characters in file name and extension whereas a question mark is used only for a single character in a filename or extension.
Rules for using wildcards::
- Question mark ? is used to represent a single character.
- Asterisk is used for one or more characters.
- Question mark ? wildcard can be used anywhere in the filename and extension for obtaining desired result.
- Same as question mark ? wildcard asterisk * can also be used anywhere in the filename and extension to obtained a desired result.
- They can be used in the beginning of filename or extension or in the middle or even in the end of the filename or extension.
- Wildcards ? and * cannot be used with quotes.
- Both wildcards can be used in a command.
- To find and fetch specific result wild card should be used intelligently.
Also Read ::
- What is a Dos Operating System
- What are Basic Dos Commands
- How to Make a Batch File
- What is Operating System and Its Different Types
- How to Create a Bootable USB Pendrive
Uses of Wildcards ::
Below are some of the examples for your understanding and learning how to use wildcards for specific purpose.
• Let say you want to copy all files from d:\movies to e: here we will use wildcard Asterisk (*) follow the below-given command. Open your Command prompt. To know more about dos and dos command click here.and type the following command in the command line.
C:\> copy d:\movies\*.* e: (Press Enter)
• To search for all files starting from letter A .use the following given command
C:\> dir/a*.* (Press Enter)
In the above given command it will search for every file starting with character A at the beginning of a file and display the result on the screen. here * after A denotes every character to search after A and * in extension denotes every character present in extension.
• Now let say you want to delete every file present in a specific directory in computer system . For Example d:\movies is the directory and you need to delete every file present in that directory.Use below-mentioned command.
- C:\>del d:\movies\*.* (Press Enter)
- Dir *A.* here the result will show all the files whose second character is A.
- Dir mo?se here the result will match record containing five characters. Like mouse,morse etc
• For searching a file which starts with initial b.
This command will fetch record starting from b with any extension name.
• To delete a filename which starts from letter C.
C:\> del c*.* (Press Enter)