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--verboseif 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--symlinkis 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 asrootin the/libdirectory. 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