RENAME(1)

โœจ RENAME(1) โ€” the user-commands era โœจ

okay bestie, pull up a chair ๐ŸŽ€ this is rename(1) from the User Commands section, and it's literally the glow-up your filenames have been waiting for ๐Ÿ’…


๐Ÿ’– NAME ๐Ÿ’–

rename โ€” it renames files. that's it. that's the whole vibe. ๐Ÿฆ‹


๐ŸŒธ SYNOPSIS ๐ŸŒธ

rename [options] substring replacement file...

๐Ÿงš DESCRIPTION ๐Ÿงš

so here's the tea โ˜• rename takes the files you point at and, in each one's name, swaps out the first place where substring shows up and drops replacement in its place. one swap per name, by default. periodt. ๐Ÿ’…


โœจ OPTIONS โœจ

  • -s, --symlink โ€” bestie, don't rename the symlink itself, change where it points instead ๐Ÿซถ
  • -v, --verbose โ€” spill which files actually got renamed (if any, no pressure)
  • -n, --no-act โ€” main-character energy but make it โœจimaginaryโœจ: no changes at all. add --verbose if you wanna peek at what would have happened ๐Ÿ‘€
  • -a, --all โ€” not just the first occurrence, babes โ€” replace every single one ๐ŸŒˆ
  • -l, --last โ€” actually, hit the last occurrence instead of the first. plot twist ๐Ÿ’€
  • -o, --no-overwrite โ€” do NOT steamroll files that already exist. and when --symlink is active, don't overwrite symlinks that point at existing targets either ๐Ÿ™ˆ
  • -i, --interactive โ€” ask before overwriting existing files. consent is iconic ๐Ÿ‘‘
  • -h, --help โ€” show the help text and dip
  • -V, --version โ€” show the version and dip

โš ๏ธ WARNING โš ๏ธ

okay this is the serious part, bestie, listen up ๐Ÿ˜ญ by default โ€” or without any one of --no-overwrite, --interactive, or --no-act โ€” the renaming has no safeguards at all. if you've got permission to rewrite file names, it will just do the thing, no questions asked, no vibe check. for example, the result can be pretty drastic when you run the command as root in the /lib directory. always make a backup before running it, unless you genuinely, truly know what you're doing. fr fr. ๐Ÿซถ

๐Ÿฆ‹ EDGE CASES ๐Ÿฆ‹

if substring is empty, then by default replacement gets tacked onto the start of the filename. but with --all? it gets inserted in between every two characters of the filename, plus at the start and at the end. unhinged and we love her for it ๐Ÿ’…

normally only the final path component of a filename gets updated. (or with --symlink, only the final path component of the link.) BUT โ€” if either substring or replacement contains a /, the full path gets updated. that can straight-up move a file between folders. creating folders, and moving files between filesystems? not supported, bestie. not in the cards. ๐Ÿšซ


๐ŸŽ€ INTERACTIVE MODE ๐ŸŽ€

like most standard utilities, rename can be used with a terminal device (tty for short) in canonical mode, where the line is buffered by the tty and you press ENTER to validate the user input. but if you put your tty in cbreak mode, rename only needs a single key press to answer the prompt. iconic, lowkey. to set cbreak mode, run for example:

sh -c 'stty -icanon min 1; "$0" "$@"; stty icanon' rename -i from to files

๐ŸŒˆ EXIT STATUS ๐ŸŒˆ

  • 0 โ€” all requested rename operations were successful โœจ
  • 1 โ€” all rename operations failed ๐Ÿ˜ญ
  • 2 โ€” some rename operations failed ๐Ÿ’€
  • 4 โ€” nothing was renamed ๐Ÿ™ˆ
  • 64 โ€” an unanticipated error occurred ๐Ÿ˜ต

โญ EXAMPLES โญ

given the files foo1, ..., foo9, foo10, ..., foo278, these commands:

rename foo foo00 foo?
rename foo foo0 foo??

will turn them into foo001, ..., foo009, foo010, ..., foo278. and:

rename .htm .html *.htm

will fix the extension of your html files. ๐ŸŽ‰

want to shorten something? hand it an empty string:

rename '_with_long_name' '' file_with_long_name.*

and it will remove the substring from the filenames. chef's kiss ๐Ÿง‘๐Ÿณ๐Ÿ’‹


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


๐Ÿ› REPORTING BUGS ๐Ÿ›

for bug reports, use the issue tracker <https://github.com/util-linux/util-linux/issues>. (yes bestie, actually report them, the maintainers are nice ๐Ÿซถ)


๐Ÿ’œ AVAILABILITY ๐Ÿ’œ

the rename command is part of the util-linux package, which can be downloaded from the Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.


and that's the whole page, bestie ๐Ÿ’– this was util-linux 2.42.4, dated 2026-09-21 โ€” go forth and rename responsibly, and for the love of everything, back up first ๐ŸŒˆ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: util-linux 2.42.4-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ISC AND LGPL-2.1-or-later AND LicenseRef-PublicDomain
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms