← Back to list

How to Rename Files in Linux

Renaming files in Linux is done using the mv (move) or rename command. The system treats renaming as moving a file to a new name in the…

VSYS Host · 2026-04-21 07:59 · 3 claps · 0.9 min read
#linux #devops #sysadmin #vsys
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud 🔓 · Open Source 🥊 · Combat Sports

How to Rename Files in Linux

Renaming files in Linux is done using the mv (move) or rename command. The system treats renaming as moving a file to a new name in the same location.

Rename a Single File (mv)

Basic syntax:

mv old_filename new_filename

Example:

mv file1.txt file2.txt

This renames a file without changing its location.

Rename Using Absolute Path

mv /path/old.txt /path/new.txt

Used when working outside the current directory.

Rename Multiple Files (mv + loop)

for f in *.txt; do
  mv -- "$f" "${f%.txt}.pdf"
done

Changes .txt.pdf for all files in a directory.

Rename Multiple Files (rename)

rename 's/old/new/' *.txt

Example:

  • replace text in filenames
  • change extensions
  • bulk rename

The rename command uses regex and is more flexible for batch operations.

Key Notes

  • mv → simple rename (single file)
  • rename → bulk rename with patterns
  • loops → needed for batch operations with mv
  • supports full paths and automation

Summary

  • rename file → mv old new
  • batch rename → rename or loops
  • use regex for advanced patterns

Full guide 👉https://vsys.host/how-to/how-to-rename-files-in-linux


메타데이터
post_id
2d0ce2d74b4c
slug
how-to-rename-files-in-linux-2d0ce2d74b4c
url
https://medium.com/@vsys.host/how-to-rename-files-in-linux-2d0ce2d74b4c
canonical_url
https://medium.com/@vsys.host/how-to-rename-files-in-linux-2d0ce2d74b4c
author_url
https://medium.com/@vsys.host
status
ok
fetched_at
2026-06-21 22:26:41