What is a Wild Card? and How to Use Them

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 the desired result.
  • Same as a question mark? wildcard asterisk * can also be used anywhere in the filename and extension to obtain the desired result.
  • They can be used at the beginning of the filename or extension or in the middle or even at 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 results wild card should be used intelligently.

Also Read ::

Uses of Wildcards

Below are some of the examples for your understanding and learning how to use wildcards for specific purposes.

• 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 the 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 the 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. c:\>Dir/s b*.* This command will fetch a record starting from b with any extension name.

• To delete a filename that starts from the letter C.

C:\> del c*.* (Press Enter)

Leave a Comment