Windows
Linux
File Management
File System
Windows ren / rename equivalent in Linux
Renames a file or batch-renames multiple files matching a pattern.
Windows
→
ren / rename
Linux equivalents
mv / rename
mv / rename
mv / rename
Overview
What this command does
Renames a file or batch-renames multiple files matching a pattern.
Migration tip: Single file renaming uses
mv. For batch renaming (e.g. change all .txt to .bak), use the rename utility which supports Perl-style patterns.Practical tasks
Common use cases
Rename files
Renames a file or batch-renames multiple files matching a pattern.
mv old new
Rename a single file
rename 's/.txt/.bak/' *.txt
Batch rename with pattern
rename -n 's/foo/bar/' *
Dry-run, preview only
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
mv report.txt report.bak
rename 's/.txt/.bak/' *.txt
rename -n 's/report/summary/' *
Walkthrough
Examples with explanations
# Windows: ren report.txt report.bak
mv report.txt report.bak # rename one file
# Windows: ren *.txt *.bak (batch)
rename 's/.txt/.bak/' *.txt # batch rename
rename -n 's/report/summary/' * # preview changes first
Reference
Common options and variations
| Command or option | Use |
|---|---|
mv old new | Rename a single file |
rename 's/.txt/.bak/' *.txt | Batch rename with pattern |
rename -n 's/foo/bar/' * | Dry-run, preview only |
rename -v | Verbose, show each rename |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | mv / rename |
Same command on this distribution. |
| Fedora | same command | mv / rename |
Same command on this distribution. |
| Arch | same command | mv / rename |
Same command on this distribution. |
Keep learning