MW

How-To · System

Windows CMD Rename Command (`ren`) — Files, Folders, Batch (2026)

The `ren` (or `rename`) command renames files and folders from Windows Command Prompt. One line for one file, a wildcard for hundreds — here's every variant.

Jan 24, 2025 3 min read Windows beginner
Advertisement

The ren (or rename) command in Windows Command Prompt renames files and folders. Simple, fast, and works on every Windows version from XP to 11. Here’s the canonical syntax:

Command Prompt — basic rename
C:\> ren oldname.txt newname.txt
C:\> dir newname.txt
01/24/2026 09:42 AM 1,234 newname.txt

This guide covers single-file renames, folder renames, wildcards for batch jobs, and the PowerShell alternative when ren isn’t enough.

Introduction to the REN command

ren is a built-in Windows command — no install, available from any cmd.exe prompt. The syntax:

ren [drive:][path]filename1 filename2

Key points:

  • Renames files and folders (single command for both)
  • Supports wildcards (*, ?) for batch operations
  • Use quotes for names with spaces
  • Can’t move files to a different folder — for that, use move instead
  • rename is an alias for ren — both work identically

Basic usage

Rename a single file

Command Prompt — single file
C:\> ren oldname.txt newname.txt
C:\> ren report.pdf report-2026-q1.pdf

Rename with a full path

Command Prompt — with path
C:\> ren C:\folder\oldname.txt newname.txt
(Note: the destination is just the new name, no path)

Rename a folder

Command Prompt — folder
C:\> ren oldfolder newfolder
C:\> ren Documents Documents-Archive

Names with spaces

Wrap both arguments in double quotes:

Command Prompt — names with spaces
C:\> ren "old folder name" "new folder name"
C:\> ren "Q1 Report.docx" "Q1-Report-Final.docx"

Change a file extension

ren handles extensions like any other rename — you just include the dot:

Command Prompt — extension changes
C:\> ren file.txt file.bak
(.txt to .bak)
C:\> ren script.txt script.bat
(make a text file executable)
C:\> ren noext.file file.txt
(add an extension to an extensionless file)

Batch renaming with wildcards

* matches any sequence of characters; ? matches a single character.

Change extension for all matching files

Command Prompt — batch by extension
C:\> ren *.txt *.bak
(renames every .txt in the current folder to .bak)
C:\> ren *.jpeg *.jpg
(.jpeg to .jpg)

Rename in a sequence

For numbered files, a for loop is the cleanest approach:

Command Prompt — sequence rename
C:\> for /L %i in (1,1,10) do ren file%i.txt newfile%i.txt
(renames file1.txt through file10.txt)

When ren falls short — PowerShell

For find-and-replace inside filenames, regex patterns, or recursive renames, PowerShell beats ren:

PowerShell — find-and-replace in filenames
C:\> Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace 'old', 'new' }
(every .txt in the folder gets "old" replaced with "new" in its name)
C:\> Get-ChildItem -Recurse *.log | Rename-Item -NewName { $_.Name -replace ' ', '-' }
(recursive: replace spaces with dashes in every .log under the current folder)

Common pitfalls

SymptomCauseFix
”The system cannot find the file specified”Old filename doesn’t exist (or you’re in the wrong folder)dir first to confirm the file exists
”Access denied”File is open in another program, or permissions issueClose the program, or open Command Prompt as Administrator
Rename works but file disappearsYou renamed it to a hidden extension; explorer hides extensions by defaultToggle “File name extensions” in Explorer’s View tab
Wildcard rename does nothingNo files match the pattern in the current folderRun dir *.txt first to verify matches

Quick reference

TaskCommand
Rename one fileren old.txt new.txt
Rename one folderren oldfolder newfolder
Names with spacesren "old name" "new name"
Change extensionren file.txt file.bak
Add extensionren noext file.txt
Batch by extensionren *.txt *.bak
Numbered sequencefor /L %i in (1,1,10) do ren file%i.txt new%i.txt
PowerShell regexGet-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace 'X','Y' }

Conclusion

The ren command is a 30-year-old fixture of Windows for good reason — it’s simple, fast, and built in. For one-off renames it’s faster than any GUI. For batch jobs, the * wildcard handles 90% of cases. For anything beyond — recursive renames, regex find-and-replace — switch to PowerShell.

Most-used forms to memorize:

  • ren old.txt new.txt — single file
  • ren "name with spaces" "new name" — with quotes
  • ren *.txt *.bak — wildcard batch
  • Get-ChildItem ... | Rename-Item ... — PowerShell when you need more
Windows CMD Command Line File Management Rename
Advertisement

Get weekly notes in your inbox

Practical tips, tutorials and resources. No spam.