RENAME(1)
โจ RENAME(1) โจ
okay bestie, welcome to rename from the User Commands girlies ๐ this is the manual page for it, and yes it's the util-linux one, not that other imposter, we'll get to that.
๐ธ NAME ๐ธ
rename โ rename files. that's it. that's the whole job. she renames files ๐
๐ SYNOPSIS ๐
rename [options] expression replacement file...
๐ฆ DESCRIPTION ๐ฆ
so basically: rename will rename the specified files by replacing the first occurrence of expression in their name by replacement.
first one only. not all of them. we'll talk about that in a sec, don't worry ๐ซถ
๐ OPTIONS ๐
-s,--symlinkโ do not rename a symlink itself, but change where it points instead. so like, the little arrow gets redirected, not the link ๐ง-v,--verboseโ show which files were renamed, if any. receipts, basically. she tells you what she did โจ-n,--no-actโ do not make any changes. nothing happens. add--verboseto see what would have been made. it's giving dress rehearsal ๐-a,--allโ replace all occurrences of expression rather than only the first one. go girl, get every single one ๐-l,--lastโ replace the last occurrence of expression rather than the first one. opposite energy, still valid ๐-o,--no-overwriteโ do not overwrite existing files. and when--symlinkis active, do not overwrite symlinks pointing to existing targets either. protective queen ๐ก๏ธ-i,--interactiveโ ask before overwriting existing files. she checks in first, consent matters ๐-h,--helpโ display help text and exit.-V,--versionโ display version and exit.
โ ๏ธ WARNING โ ๏ธ
okay bestie, sit down, this one is serious ๐ญ
the renaming has no safeguards by default, or without any one of the options --no-overwrite, --interactive or --no-act. if the user has permission to rewrite file names, the command will perform the action without any questions.
for example, the result can be quite drastic when the command is run as root in the /lib directory. ๐
always make a backup before running the command, unless you truly know what you are doing. like, fr fr. no cap. back it up. ๐
๐ EDGE CASES ๐
if the expression is empty, then by default replacement will be added to the start of the filename. but with --all, replacement will be inserted in between every two characters of the filename, as well as at the start and end. yeah. every gap. she's thorough โจ
normally, only the final path component of a filename is updated. (or with --symlink, only the final path component of the link.) but if either expression or replacement contains a /, the full path is updated. this can cause a file to be moved between folders. creating folders, and moving files between filesystems, is not supported. so like, don't expect her to build you a directory, she won't ๐ค
๐ง INTERACTIVE MODE ๐ง
as most standard utilities, rename can be used with a terminal device (tty in short) in canonical mode, where the line is buffered by the tty and you press ENTER to validate the user input.
if you put your tty in cbreak mode however, rename requires only a single key press to answer the prompt. iconic. one tap and done ๐
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. slay ๐1โ all rename operations failed. oh no ๐ญ2โ some rename operations failed. a mixed bag, we don't love that ๐ซ4โ nothing was renamed. she showed up and did absolutely nothing ๐64โ unanticipated error occurred. mystery behaviour, not the fun kind ๐
๐ EXAMPLES ๐
given the files foo1, ..., foo9, foo10, ..., foo278, the commands
rename foo foo00 foo?
rename foo foo0 foo??
will turn them into foo001, ..., foo009, foo010, ..., foo278. yes the zero-padding math works out, trust โจ
and
rename .htm .html *.htm
will fix the extension of your html files. glow-up for your file extensions ๐
provide an empty string for shortening:
rename '_with_long_name' '' file_with_long_name.*
will remove the substring in the filenames. bye bye, substring ๐ฆ
๐ SEE ALSO ๐
๐ REPORTING BUGS ๐
for bug reports, use the issue tracker <https://github.com/util-linux/util-linux/issues>. tell them everything, bestie, they wanna know ๐ซถ
โญ AVAILABILITY โญ
the rename command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.
util-linux 2.41.5 ๐ธ 2026-06-16 โ that's the version and the date, mwah, love that for her, and love that for you too. go rename something responsibly, bestie ๐โจ๐๐ฆ๐ธ๐
๐ฆ where this page comes from
- debian trixie: util-linux 2.41.5-0+deb13u1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms