Mastering the ren Command in Windows

Need to rename files in bulk? Change file extensions quickly? Fix a hundred messy filenames with one line?
The ren command is your lightweight, no-nonsense solution — and it’s been quietly rocking the Windows CLI since the MS-DOS days.

Let’s give it some well-deserved attention.

What Is ren?

ren (or rename) is a simple Windows command-line utility used to rename files and folders.
It’s lightning fast, no install needed, and comes pre-installed in every version of Windows.

It’s like mv on Linux, but specifically for renaming — not moving.


Basic Syntax

cmd
ren [source] [newname]

Yep — that’s it. No weird flags, no long-winded options.

Example 1: Rename a single file

cmd
ren report1.txt final_report.txt

report1.txt is now final_report.txt

Example 2: Rename all .txt files to .bak

cmd
ren *.txt *.bak

All files like notes.txt, data.txt, todo.txt → become notes.bak, data.bak, etc.

💡 This is one of ren‘s secret powers: it supports simple wildcards (* and ?).

Example 3: Rename a bunch of files by pattern

Let’s say you have:

cmd
IMG_001.jpg
IMG_002.jpg
IMG_003.jpg

And you want to remove the prefix IMG_. Unfortunately, ren alone can’t do that — but here’s a batch script workaround:

BAT (Batchfile)
@echo off
for %%f in (IMG_*.jpg) do (
  set "old=%%f"
  setlocal enabledelayedexpansion
  ren "%%f" "!old:~4!"
  endlocal
)

This uses basic string slicing (~4) to chop off the first 4 characters (IMG_).

🗂️ Rename Folders Too

Yes, ren works on folders as well!

cmd
ren OldProject NewProject

Just be sure the folder isn’t in use or open in Explorer.

Let’s say you have a folder named Hello under c:\tmp and there’s a file myfile.txt inside this folder opened for editing.

if you run now the ren command it will fail:

cmd
C:\Tmp>ren Hello HelloThere
The process cannot access the file because it is being used by another process.

Limitations

LimitationWorkaround
No built-in support for regexUse PowerShell for advanced renaming
Can’t rename with path changesUse move or robocopy instead
Can’t rename hidden/system filesUse attrib to unhide first

Final Thoughts

The ren or rename command might not have a thousand options or a fancy UI, but that’s what makes it great. It does one thing, and it does it fast. Once you get comfortable with wildcards and a bit of scripting, you’ll be renaming like a pro in no time.

Next time you need to clean up a folder full of messy filenames — don’t reach for the mouse. Open a terminal, and type ren.

Want to see a PowerShell version of this with regex support and preview mode? Drop a comment and I’ll whip up a sequel! 😄

Leave a Comment