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 --verbose to 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 --symlink is 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