The Command Prompt is a powerful tool built into most computers running the Windows operating system. It is a command line interpreter that you’re able to use to perform just about any task, including things like renaming files.

While you can also rename files through File Explorer, doing so in Command Prompt can be much faster if you know how. Additionally, you can also batch rename files in the Command prompt which can massively increase your efficiency.

renamming-files-with-spaces-in-cmd

Rename Files on Command Prompt

The simplest way to rename files inCommand Promptis by going to that specific file’s directory and using theren/renamecommand. Its syntax isrename filename newname.

When using it practically, replace thefilenamewith the file’s actual name andnewnamewith the name you want to set. you’re able to also usereninstead of rename as both are the same command.

cmd-on-run-3

However, before you go on to use the command, there are a few things to keep in mind.

Now that you know the basic rules to follow when using the rename command, here’s how you can go about using it.

change-cmd-directory-with-cd

Additionally, if you don’t like using thecd commandto change your active directory, there is another method you can use. Navigate to the file location inFile Explorer, typecmdin theaddress barand pressEnter. This will directly open Command Prompt in that directory.

Alternatively, you may tweak the rename command a little so that you don’t have to change your directory to rename files. The syntax for this altered command isrename “file path location” newname.

change-drive-in-command-prompt

For example,rename “C:\Screenshots\20190213.jpg” “Sun Tzu Quote.jpg”

Batch Rename Files on Command Prompt

The best use of the rename command is when you’re trying to rename many files simultaneously. To batch rename files in the Command prompt, you will have to know about the two key wildcards,*and?.

Using * Wildcard

Thecharacter is basically used to select all the files at once, but it is low in priority order. For example, therename Photo.jpg Image*.jpgwill change any image file beginning with the name Screenshot to Image with the same characters following after.

In a nutshell, if your images were labeledPhoto1,Photo2, and so on, the above command will change them toImage1,Image2, and so on.

file-path-directions

If you want to rename files without having to specify their extensions, you may use the*wild card to do so as well. For example,rename Untitled.jpg Image.*will make sure that your renamed file has the same extension as its earlier version.

Also, you can use the*wildcard to rename all files with a particular extension to another extension. For example,rename *.txt *.docxwill ensure any files with the.txtextension will get renamed to.docx.

rename-files-in-command-prompt

Using ? Wildcard

The?character can be used as a placeholder to replace itself with the character in the same position as itself. You can use this character in conjunction with the*character to batch rename files and trim specific files.

For instance, therename . ?????.*will trim every file to its first five characters. You can add or remove as many?wildcards to expand or lower the character count.

renaming-files-in-command-prompt-with-the-asterisk

Also, you can specify the extension in the filename to only target specific files. For example,rename *.jpg ?????.*will trim every jpg file to its first five characters.

Another way you can use this?wildcard is at the filename to specify files with varying lengths of name characters. For instance, therename “?????.jpg” “?????2022.*”will add 2022 to every jpg file that has five characters in its name.

rename-file-extension-without-specifying-extension-in-cmd

If you’d like a more in-depth explanation onbatch renaming filesand wildcard characters, you can check out our other article.

rename-file-extension-in-cmd

trim-filenames-from-cmd

add-characters-to-filename-from-cmd