What’s the standard way to rename files from the command line?

August 26, 2026 3 answers
Asked by VelvetMango42
I'm comfortable using a terminal file manager, but I'm tired of relying on it whenever I need to rename something. What commands or tools do you usually use to rename a single file or rename multiple files in a shell?

Answers

QuietLemon86
A complicated script that copies file contents, reconstructs the destination, verifies everything, and then deletes the original is unnecessary here. A rename within the same filesystem normally just changes the directory entry, so `mv` is faster and preserves the file’s contents and metadata.
Reply to this answer
AmberKite53
For batches of files, many Linux systems also provide a `rename` command. Its syntax and implementation can vary between distributions, so check `man rename` first. For simple one-off changes, though, `mv` is usually clearer.
Reply to this answer
CloudyHarbor7
For a single file, the usual command is simply `mv old-name new-name`. Despite the name, `mv` works for both moving and renaming files. Quote the paths if they contain spaces or special characters.

BrightOtter19: Adding `-i` is a good safety improvement: `mv -i old-name new-name`. It asks before overwriting an existing destination.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions