CMD Simulator
File Managementren

REN Command – Rename Files and Directories in Windows CMD

Master the REN command to rename files and folders in Windows Command Prompt. Complete guide with syntax, wildcards, examples, and best practices for renaming.

Rojan Acharya·
Share

The REN command (Rename) is a Windows Command Prompt utility that changes the name of files or directories without moving them to a different location, preserving their position in the file system. Use REN to rename single files, batch rename multiple files with wildcards, change file extensions, or rename directories; the full command RENAME works identically—both provide instant in-place renaming without relocation or duplication.

Whether you're a system administrator standardizing file naming conventions, a developer renaming project files to match coding standards, or a power user organizing file collections, REN provides reliable file and directory renaming with wildcard support for batch operations. IT professionals rely on REN for automated file renaming, naming convention enforcement, and file organization across enterprise environments.

This comprehensive guide covers REN syntax, all parameters and wildcard patterns, practical examples for common renaming scenarios, troubleshooting tips for renaming failures, related file management commands, and frequently asked questions. By the end, you'll confidently rename files and directories from the command line for file organization, naming standardization, and batch renaming tasks.

What Is the REN Command?

The REN command is a file system management tool in Windows Command Prompt that renames files and directories in place without relocating them. Unlike MOVE, which can both rename and relocate, REN only changes the name while keeping the file or directory in its current location.

REN supports wildcards (* and ?) for batch renaming operations, making it efficient for renaming multiple files that follow a pattern. The command works in Command Prompt (CMD), Windows PowerShell (with CMD compatibility), Windows Terminal, and is available in all Windows versions from MS-DOS through Windows 11, Windows Server 2022, and all enterprise editions.

The command has a full name RENAME that functions identically to REN. Most users prefer REN for brevity in interactive sessions, but RENAME is clearer in scripts and documentation. Both commands accept the same syntax and produce identical results.

REN vs MOVE vs COPY

  • REN: Renames files/directories in place; no relocation; preserves position
  • MOVE: Renames and/or relocates; can move to different directories or drives
  • COPY: Duplicates files with new names; preserves originals

Use REN for simple renaming without relocation, MOVE for renaming with relocation, and COPY for creating renamed duplicates.

Syntax

REN [drive:][path]oldname newname
RENAME [drive:][path]oldname newname

Parameters

ParameterDescription
[drive:][path]Specifies the location of the file or directory to rename (optional)
oldnameSpecifies the current name of the file or directory (wildcards supported)
newnameSpecifies the new name (must not include a path; wildcards supported)

Important: The newname parameter must not include a path. REN only renames in place—it cannot move files to different directories. To rename and relocate, use MOVE instead.

Wildcards: REN supports * (any characters) and ? (single character) in both oldname and newname for batch renaming operations.

How to Use REN Command

Rename a Single File

Change a file's name in the current directory:

REN oldfile.txt newfile.txt
REN report-draft.docx report-final.docx

The file remains in the same directory with a new name.

Rename a File with Full Path

Specify the complete path to rename a file in any location:

REN C:\Documents\report.txt final-report.txt
REN D:\Projects\app.js application.js

Only the filename changes; the path remains the same.

Rename a Directory

Change a folder's name without moving it:

REN OldFolderName NewFolderName
REN C:\Projects\OldApp NewApp

The directory remains in the same parent folder with a new name.

Rename Multiple Files with Wildcards

Use wildcards to batch rename files matching a pattern:

REN *.txt *.bak
REN report*.docx final*.docx
REN data?.csv archive?.csv
  • *.txt *.bak renames all .txt files to .bak extension
  • report*.docx final*.docx changes "report" prefix to "final"
  • data?.csv archive?.csv renames data1.csv to archive1.csv, data2.csv to archive2.csv

Change File Extension

Rename all files of one type to another extension:

REN *.htm *.html
REN *.jpeg *.jpg
REN *.txt *.log

This changes file extensions for all matching files in the current directory.

Rename with Pattern Matching

Use ? wildcard to preserve parts of filenames while changing others:

REN file?.txt document?.txt
REN report-????.docx final-????.docx
  • file?.txt document?.txt renames file1.txt to document1.txt, file2.txt to document2.txt
  • ???? preserves four characters: report-2026.docx becomes final-2026.docx

Rename Files with Spaces

Enclose names containing spaces in double quotes:

REN "old name.txt" "new name.txt"
REN "My Document.docx" "Final Document.docx"

Without quotes, Windows treats each word as a separate argument.

Rename to Remove Spaces

Remove spaces from filenames:

REN "file name.txt" filename.txt
REN "my document.docx" mydocument.docx

This consolidates filenames by removing spaces.

Rename Files in Subdirectories

Navigate to the subdirectory first, then rename:

CD C:\Projects\App
REN config.txt settings.txt

Or specify the full path:

REN C:\Projects\App\config.txt settings.txt

Rename with Uppercase/Lowercase

Change file case (note: Windows file system is case-insensitive for display but preserves case):

REN readme.txt README.txt
REN Config.ini config.ini

Windows preserves the case you specify, though file access is case-insensitive.

Common Use Cases

  1. Rename individual files – Use REN to change file names without moving them, ideal for correcting typos or updating naming conventions.

  2. Change file extensions – Use REN *.oldext *.newext to convert file types in bulk, useful for standardizing file formats.

  3. Rename directories – Use REN to change folder names in place without affecting contents or location.

  4. Batch rename files – Use REN with wildcards to rename multiple files at once, saving time on repetitive renaming tasks.

  5. Correct typos – Use REN to fix misspelled file or folder names quickly from the command line.

  6. Standardize naming – Use REN in scripts to enforce naming conventions across files, ensuring consistency in projects or systems.

  7. Prepare files for processing – Use REN to rename files before batch operations, ensuring they match expected naming patterns.

  8. Organize downloads – Use REN to rename downloaded files with descriptive names for easier identification and organization.

  9. Update version numbers – Use REN to update version numbers in filenames for software releases or document revisions.

  10. Remove special characters – Use REN to clean filenames by removing or replacing special characters that cause issues in scripts or applications.

  11. Implement file naming policies – Use REN in scheduled tasks to enforce organizational file naming standards automatically.

  12. Prepare files for archiving – Use REN to add prefixes or suffixes to files before archiving for better organization and retrieval.

Tips and Best Practices

  1. The new name must not include a path – REN only renames in place. To rename and move, use MOVE: MOVE oldpath\old.txt newpath\new.txt.

  2. Quote names with spaces – Enclose filenames containing spaces in double quotes: REN "old name.txt" "new name.txt". Without quotes, Windows treats each word as a separate argument.

  3. Use wildcards carefully – Preview with DIR before renaming: DIR *.txt then REN *.txt *.bak. This shows exactly which files will be renamed.

  4. REN fails if target name exists – If a file with the new name already exists, REN displays "A duplicate file name exists" and fails. Delete or rename the conflicting file first.

  5. Cannot rename across drives or directories – REN only renames in the current location. Use MOVE for cross-directory or cross-drive renaming.

  6. Use ? wildcard to preserve charactersREN file?.txt doc?.txt preserves the character in the ? position: file1.txt becomes doc1.txt.

  7. Combine with FOR loops for complex renaming – Use FOR loops in batch scripts for advanced renaming logic beyond simple wildcards.

  8. Test with non-critical files first – Practice REN commands with test files before running them on important data to avoid accidental renaming errors.

  9. Use DIR to preview wildcard matches – Always run DIR pattern before REN pattern newpattern to verify which files will be affected.

  10. REN preserves file attributes – Hidden, read-only, and system attributes are preserved when renaming files.

  11. Use REN for case changes – Windows file system is case-insensitive but preserves case. Use REN to change file case for display purposes.

  12. Document renaming operations – In scripts, add comments explaining renaming logic to aid future maintenance and troubleshooting.

Troubleshooting Common Issues

"A duplicate file name exists" Error

Problem: REN displays "A duplicate file name exists, or the file cannot be found" and fails.

Cause: A file with the new name already exists in the same directory.

Solution: Check for existing files:

DIR newname.txt

Delete or rename the conflicting file first:

DEL newname.txt

Or choose a different name:

REN oldname.txt differentname.txt

Prevention: Use DIR to check for name conflicts before renaming. Choose unique names or clean up conflicting files first.

"The system cannot find the file specified" Error

Problem: REN reports it cannot find the specified file.

Cause: File doesn't exist, incorrect path, typo in filename, or file is hidden.

Solution:

  • Verify the file exists with DIR oldname
  • Use DIR /A:H to list hidden files
  • Check for typos in the filename
  • Use Tab completion to auto-complete filenames
  • Enclose paths with spaces in double quotes

Prevention: Use DIR to verify files exist before attempting to rename them. Copy filenames from DIR output to avoid typos.

Cannot Rename File to Different Directory

Problem: REN fails when trying to include a path in the new name.

Cause: REN only renames in place—it cannot move files to different directories.

Solution: Use MOVE instead:

MOVE oldpath\oldname.txt newpath\newname.txt

Or use REN for renaming, then MOVE for relocation:

REN oldname.txt newname.txt
MOVE newname.txt newpath\

Prevention: Use MOVE when you need to rename and relocate simultaneously. Use REN only for in-place renaming.

Wildcards Rename Wrong Files

Problem: Using REN *.txt *.bak renames more files than expected.

Cause: Wildcards match all files fitting the pattern, including hidden or system files.

Solution: Preview files before renaming:

DIR *.txt

Then run REN with the same pattern:

REN *.txt *.bak

Use more specific wildcards: REN report-*.txt instead of *.txt.

Prevention: Always use DIR with the same wildcard pattern to preview affected files before running REN.

REN Doesn't Preserve Part of Filename

Problem: Using REN file*.txt doc*.txt doesn't preserve the middle part of filenames.

Cause: Wildcards in newname don't directly correspond to wildcards in oldname.

Solution: Use ? for character-by-character preservation:

REN file?.txt doc?.txt

This preserves the character in the ? position.

For complex renaming, use FOR loops:

FOR %f IN (file*.txt) DO REN "%f" "doc%~nxf"

Prevention: Understand wildcard behavior. Use ? for positional preservation or FOR loops for complex renaming logic.

Cannot Rename Hidden or System Files

Problem: REN appears to succeed but files aren't renamed.

Cause: Files may be hidden or have system attributes, or you're not seeing them in DIR output.

Solution: List all files including hidden:

DIR /A

REN works on hidden and system files without requiring attribute changes:

REN hiddenfile.txt newname.txt

Prevention: Use DIR /A to see all files before renaming. REN can rename hidden and system files without clearing attributes.

Related Commands

MOVE – Move and Rename Files

MOVE relocates files and can rename them simultaneously. Use when you need to rename and move to a different directory.

Key difference from REN:

  • MOVE can rename and relocate
  • REN only renames in place

Example:

MOVE C:\Source\old.txt D:\Destination\new.txt

When to use: Renaming with relocation, moving files between directories or drives.

COPY – Copy with New Name

COPY duplicates files with new names. Use when you want to create renamed copies while preserving originals.

Example:

COPY original.txt backup-original.txt

When to use: Creating renamed backups or duplicates.

ATTRIB – Display File Attributes

ATTRIB shows file attributes. Use to verify file properties before renaming.

Example:

ATTRIB filename.txt

Integration: Check file attributes before renaming to understand file properties.

DIR – List Files

DIR displays directory contents. Use before REN to preview files that will be renamed.

Example:

DIR *.txt
REN *.txt *.bak

Integration: Always preview with DIR before batch renaming with REN.

FOR – Loop Through Files

FOR loops through files in batch scripts. Use for complex renaming logic beyond simple wildcards.

Example:

FOR %f IN (*.txt) DO REN "%f" "prefix-%f"

When to use: Advanced batch renaming with custom logic, prefixes, suffixes, or transformations.

FORFILES – Select Files by Criteria

FORFILES selects files based on date, size, or attributes. Use with REN for date-based or conditional renaming.

Example:

FORFILES /D -30 /C "CMD /C REN @file old-@file"

Renames files older than 30 days with "old-" prefix.

When to use: Conditional renaming based on file properties.

Frequently Asked Questions

What does REN do if a file with the new name already exists?

REN displays an error message: "A duplicate file name exists, or the file cannot be found." The command fails and does not overwrite the existing file. Delete or rename the conflicting file first, or choose a different name: DEL newname.txt then REN oldname.txt newname.txt.

How do I rename multiple files at once?

Use wildcards: REN *.txt *.bak renames all .txt files to .bak. For more complex patterns, use FOR loops in batch scripts: FOR %f IN (*.txt) DO REN "%f" "prefix-%f". Alternatively, use PowerShell's Rename-Item for advanced batch renaming with custom logic.

What is the difference between REN and RENAME?

There is no difference; REN and RENAME are identical commands. REN is simply a shorter alias for RENAME. Both accept the same syntax and parameters and produce the same results. Most users prefer REN for brevity, but RENAME is clearer in scripts and documentation.

Can REN move files to a different directory?

No, REN only renames files and directories in their current location. To move and rename simultaneously, use MOVE oldpath\oldname.txt newpath\newname.txt. REN fails if you include a path in the new name. Use MOVE for relocation, REN for in-place renaming.

How do I rename a file to remove spaces?

Use quotes around names with spaces: REN "file name.txt" filename.txt. This renames "file name.txt" to "filename.txt" by removing the spaces. Always quote the old name if it contains spaces, and quote the new name if you want to add spaces.

Can REN rename hidden or system files?

Yes, REN can rename hidden or system files without requiring attribute changes. However, you must know the exact filename. Use DIR /A to list hidden and system files before renaming: DIR /A then REN hiddenfile.txt newname.txt.

How do I change file extensions with REN?

Use wildcards: REN *.htm *.html changes all .htm files to .html. This works for any extension: REN *.txt *.log, REN *.jpeg *.jpg. The command renames all matching files in the current directory.

Can I use REN in batch scripts?

Yes, REN is commonly used in batch files for automated file renaming. Example:

@echo off
FOR %%f IN (*.txt) DO REN "%%f" "backup-%%f"

This adds "backup-" prefix to all .txt files. Use %% for loop variables in batch files (single % in interactive CMD).

What does REN . do?

REN *.* requires a new name pattern. Example: REN *.* *.bak renames all files to .bak extension. Without a valid new name pattern, REN displays a syntax error. Always specify both old and new name patterns.

How do I rename files with numbers?

Use ? wildcard to preserve numbers: REN file?.txt doc?.txt renames file1.txt to doc1.txt, file2.txt to doc2.txt. For more complex numbering, use FOR loops in batch scripts with custom logic.

Can REN rename directories?

Yes, REN renames directories just like files: REN OldFolder NewFolder. The directory remains in the same parent location with a new name. All contents are preserved. To move and rename a directory, use MOVE or ROBOCOPY.

Why doesn't REN work with paths in the new name?

REN is designed for in-place renaming only—it cannot move files to different directories. This is a deliberate limitation inherited from DOS. To rename and relocate, use MOVE: MOVE oldpath\old.txt newpath\new.txt.

Quick Reference Card

CommandPurposeExample Use Case
REN old.txt new.txtRename fileChange filename
REN *.txt *.bakChange extensionsConvert file types
REN folder newfolderRename directoryChange folder name
REN file?.txt doc?.txtPattern renamePreserve numbers
REN "old name.txt" "new.txt"Rename with spacesHandle spaces
REN *.htm *.htmlStandardize extensionsNormalize file types
REN report*.docx final*.docxChange prefixUpdate naming
DIR *.txt then REN *.txt *.logPreview then renameSafe batch rename
REN C:\path\old.txt new.txtRename with pathSpecify location
FOR %f IN (*) DO REN "%f" "new-%f"Add prefixBatch prefix

Try REN Command Now

Ready to practice renaming files and directories? Use our Windows Command Simulator to run REN commands safely in your browser. No installation required—practice REN, wildcard operations, and batch renaming in a risk-free environment. Perfect for learning, training, or testing command sequences before running them on production systems.

Explore the full Commands Reference for more Windows CMD utilities, including file management (COPY, MOVE, DEL), directory operations (MKDIR, RMDIR, CD), and system administration commands.

Summary

The REN command is the essential Windows tool for renaming files and directories from the command line. Use REN to change file or folder names in place, batch rename multiple files with wildcards, change file extensions, or standardize naming conventions across file collections.

Unlike MOVE, REN only renames without relocating, making it ideal for quick name changes without affecting file location. Use wildcards for batch operations: REN *.txt *.bak changes all text files to backup files, REN file?.txt doc?.txt preserves numbers while changing prefixes.

Master REN for file organization, naming standardization, extension changes, and batch renaming operations. Understanding REN's in-place renaming limitation and wildcard patterns ensures efficient file management in Windows environments. For renaming with relocation, use MOVE; for complex batch renaming, combine REN with FOR loops or use PowerShell's Rename-Item.