How to Enable Dark mode in dbeaver | Step-by-Step Guide ?
Using a Graphical interface to interact with your laptop is an easy job. But, using the Command Line Interface is the next level. CLI-based tasks are faster and memory efficient for the computer system. So, many computer geeks prefer using the Command Line over the Graphical Interface. You can use the Command prompt in Windows to perform your tasks effectively. It is a powerful Command Line Interface to perform different tasks on your computer system. In this article, we will be learning to use the command prompt to use wildcards to rename files.
Before learning how to use wildcards to rename files in cmd, let’s learn to open the Command Prompt. Follow the steps below:
Another way to open Command Prompt is as follows:
Two characters * (asterisk) and ? (question mark) are termed wildcard characters in the command prompt. These special characters are used to match one or more characters in the file and folder names.
In cmd, the asterisk sign * matches the sequence of characters (including an empty string), and the question mark ‘?’ matches a single character.
In this article, we will be using some of the basic commands in the command prompt. The following commands will be used in this article:
SN | Commands | Syntax |
1 | dir | dir |
2 | cd | cd <path> |
3 | ren | ren <current_file_name> <new_file_name> |
4 | cls | cls |
Follow the steps below to rename files using wildcards in the command prompt:
Step 1: Open the command prompt. fig. Open Command Prompt
Step 2: Enter the Drive letter, followed by a colon ( : ) where you have the files to be renamed. fig. Enter the Drive Letter with colon and press Enter
Step 3: Use the command cd, followed by the directory name, to enter the desired directory.
fig. Change Directory
You can escape these steps by simply following the steps below:
Step4: Type dir in the command prompt to view the files and sub-directories in the current directory.
You can use wildcards along with the dir command. Look at these examples:
a. dir *.mp4 command displays every file name with an extension .mp4.
b. Similarly, if dir IMG_2020*.jpg is used, then every file starting with IMG_2020 and having extension .jpg would be displayed.
c. Using dir IMG_20211???_* displays all the files starting with IMG_20211, followed by three unknown characters, an underscore ( _ ), and remaining unknown characters. Each of the three question marks represents an unknown individual character. The asterisk sign represents every unknown character after the underscore.
Step 5: Use the ren command followed by the existing file name and the new file name. This will rename the file. See the examples below:
a. ren *.jpg *.png renames all the files with the extension name ‘.jpg’ to ‘.png’.
b. The command ren "IMG*" "///Y*" renames all the files starting with IMG. The forward slash ( / ) means to remove a character. The first three characters are removed. The fourth character is replaced by the letter ‘Y’. The other characters remain the same.
c. You can expect to rename all files starting with Y by using the command
The new file name starts with Y. It is followed by a set of characters of the original file name till an underscore ( _ ). The characters after the underscore are replaced by “flowers”. (Note: If the file name coincides after the changes, messages like those in the below images will appear. Also, if you don’t assign .* after flowers, all the new file names will have double full stops.)
Using this command, you can add ‘video’ at the tail of every filename starting with ‘2’. Make sure the number of question marks is greater than the longest filename. Otherwise, the desired result won’t be obtained.
In this way, you can use wildcards to rename the files in the command prompt. You can also view the files and sub-directories with the help of the dir command and wildcard characters. Keep in tune that the ren command is not reversible. So, make sure to use it only after assuring the need for changes.
Using the command prompt to rename files saves time. It might be a bit difficult to learn these commands. But, once you get some days of practice, you will find it faster and easier. The Command prompt is a powerful tool and one must be careful using it. You can easily rename multiple file names at once using the wildcard characters in the Command prompt.