Rename Multiple File Extensions in Windows Command Prompt
In this article
To rename multiple file extensions at once in Windows, use the Command Prompt's built-in ren command with a wildcard. For example, ren *.txt *.md changes every .txt file in the current folder to .md. This works for any extension change, and you can also use it to add or remove extensions. You need to open Command Prompt (or PowerShell) and navigate to the folder containing the files. No extra tools or downloads are required.
What You'll Need
- A Windows PC (Windows 10 or 11 works, but the steps are similar on older versions).
- Permission to modify the files (you must be logged in with an account that can write to that folder).
- Basic comfort with typing commands—nothing else.
Step-by-Step
- Open Command Prompt. Press Win + R, type
cmd, and press Enter. Alternatively, search for "Command Prompt" in the Start menu and click it. (If you're on PowerShell, the samerencommand works.) - Navigate to your folder. Use the
cd(change directory) command. For example, if your files are inC:\Users\YourName\Documents\Files, type:cd C:\Users\YourName\Documents\Filesand press Enter. You can also drag-and-drop the folder path into the Command Prompt window after typingcd(with a space) to paste the full path. - Verify you're in the right place. Type
dirand press Enter. You'll see a list of files. Confirm the extensions you want to change are visible. - Run the rename command. The basic syntax is:
ren *.oldExtension *.newExtension
For example, to change all .jpg to .png:ren *.jpg *.pngand press Enter. - Check the result. Type
diragain to see the new extensions. If everything looks correct, you're done.
That's the core method. But there are variations you might need:
- Rename only files that start with a certain name: Use a more specific wildcard. For example,
ren report*.docx *.pdfchanges only files that start with "report" and end with .docx. - Remove an extension entirely: Use a dot followed by nothing. Example:
ren *.bak .will remove the .bak extension from all files (leaving the base name). - Add an extension to files that have none: Use
ren * *.txtto add .txt to every file that currently has no extension. (Note: this will also affect folders? No—folders are not affected byrenunless you use/s.) - Rename in subfolders too: Add
/sto the command:ren /s *.jpg *.png. This will change extensions in the current folder and all subfolders. Be careful—this affects every matching file in the entire tree.
Common Mistakes
- Using the wrong wildcard syntax. The
rencommand uses*for any characters and?for a single character. For example,ren *.jpg *.pngis correct, butren *.jpg png(missing the asterisk) will fail or rename incorrectly. - Not being in the right folder. If you run the command from a different directory, you'll get "The system cannot find the file specified." Always check with
dirfirst. - Forgetting that extensions are part of the filename. If a file is named
photo.jpg, changing to*.pnggivesphoto.png—it does not keep the old extension as part of the name. - Using
renon files that are open in another program. Windows will block the rename if the file is locked (e.g., open in Word or a photo viewer). Close the file first. - Assuming it works on files with multiple dots. For a file like
archive.tar.gz,ren *.gz *.zipwill change only the last extension, givingarchive.tar.zip. That's usually what you want, but be aware.
Tips
- Test on a copy first. If you're unsure, copy a few files to a test folder and run the command there. Verify the results before doing it on your real files.
- Use
renwith a full path if you don't want to navigate. You can specify the full path in the command:ren C:\Users\YourName\Documents\*.txt *.md—but note that the output files stay in the same folder. - For mass renaming with more control (like adding numbers or changing parts of names), use PowerShell or a dedicated file manager. The Command Prompt
renis limited to extension changes; for complex renames, PowerShell'sGet-ChildItem | Rename-Itemis more flexible. - If you need to undo a rename, keep a backup. There's no built-in undo for
ren. If you change .jpg to .png and later want to revert, you'd runren *.png *.jpg—but if you also changed names, you can't easily reverse it. - Use
/?for help. Typeren /?to see the official syntax and options.
Troubleshooting
If the command doesn't work as expected, try these in order:
- Check for typos. Re-read the command. A missing space or asterisk can cause a syntax error.
- Confirm the files exist. Run
dirand look for the exact extension. Windows is case-insensitive, so.JPGand.jpgare treated the same, but the wildcard must match the pattern. - Close any programs that might be using the files. If you get "The process cannot access the file because it is being used by another process," close the file in the other app and try again.
- Check if you have permission. If you get "Access is denied," you may need to run Command Prompt as administrator. Right-click Command Prompt and select "Run as administrator," then navigate to the folder and retry.
- If you're trying to rename files with no extension, the wildcard
*matches them, but you must be careful:ren * *.txtwill add .txt to every file that has no extension, but it will also try to rename folders? Actually,rendoes not affect folders unless you use/s; it only works on files. So it's safe. - If nothing happens, you might be using the wrong command. In PowerShell, the
renalias works, but if you typedrenameit might prompt for arguments. UserenorRename-Item.
If all else fails, open File Explorer, select the files, press F2 to rename one, and then use the built-in bulk rename (Windows 11 has a built-in bulk rename tool, but Windows 10 does not—you'd need a third-party tool).
Frequently Asked Questions
Can I rename extensions for files in multiple folders at once?
Yes, but you need to use the /s switch: ren /s *.jpg *.png. This will recurse through all subfolders. However, it will also change files in subfolders that you might not intend to change, so use it carefully.
Does renaming an extension change the file format?
No, it only changes the label. The file's actual content remains the same. If you change a .txt to .docx, it will still be a plain text file, and Word may show a warning when opening it. To truly convert formats, you need a converter program.
What if I want to rename only part of the filename, not just the extension?
For that, you need more than the ren command. Use PowerShell with a loop, or use a batch script with for. For example, to replace "old" with "new" in all filenames, you'd use a PowerShell command like Get-ChildItem | Rename-Item -NewName {$_.Name -replace 'old','new'}.
Can I undo a bulk extension rename?
Only if you remember the original extension. You can run the reverse command, e.g., if you changed .jpg to .png, run ren *.png *.jpg. But if you also changed the base names, you can't easily undo it. Always back up important files first.
Why do I get "The system cannot find the file specified" when I run ren?
This usually means you're not in the correct folder, or the wildcard doesn't match any files. Double-check your current directory with cd and dir, and make sure the extension you're targeting exists.
Does this work on Windows 11 as well?
Yes, the ren command works identically in Windows 11, Windows 10, and older versions. The Command Prompt is still available, though you might prefer PowerShell, which also supports ren as an alias.