RENAME(1)

πŸ“¦ version 1.16.3, in arch rolling

πŸŽ€ RENAME(1) β€” the perl-powered renamer πŸ’…

okay so first things first, bestie: this page lives in the User Contributed Perl Documentation section, and it's about rename β€” yes, the one that renames multiple files using perl expressions. genuinely iconic.

✨ NAME ✨

rename β€” rename multiple files using perl expressions πŸ¦‹

✨ SYNOPSIS ✨

rename [-bcfgilnv] [-B prefix] [-C command] [-S suffix] [-V method] [-Y
prefix] [-z suffix] [--backup] [--command=command] [--copy]
[--basename-prefix=prefix] [--dry-run] [--force] [--help] [--no-stdin]
[--interactive] [--just-print] [--link-only] [--prefix=prefix]
[--suffix=suffix] [--verbose] [--version-control=method] [--version]
perlexpr [files]...

✨ DESCRIPTION ✨

so rename renames the filenames you hand it, according to the rule you give as the first argument. that argument is a Perl expression, and the whole vibe is that it's expected to modify the $_ string for at least some of the filenames you listed. πŸͺ„

lowkey important: if a filename doesn't get modified by your expression, it does not get renamed. no change, no rename, periodt.

and if you give no filenames on the command line, the filenames get read via standard input β€” unless you passed --no-stdin on the command line (more on that below πŸ‘€).

🫢 also: if a destination file is unwritable, and standard input is a tty, and you didn't give -f or --force, then rename will prompt you about whether to overwrite the file. if your response doesn't begin with y or Y, the file gets skipped. no cap.

πŸ’– OPTIONS πŸ’–

  • -b, --backup β€” make backup files πŸ’Ύ. meaning: when it's about to overwrite a file, rename the original instead of removing it. the deets on how backup file names get determined live in the -V / --version-control option.
  • -B prefix, --prefix=prefix β€” use the simple method to determine backup file names (peep the -V method / --version-control=method option), and prepend prefix to a file name when generating its backup file name.
  • -c, --copy β€” copy files to the new names instead of renaming them 🫢. this keeps the original files. (yes, this is the "i want both" option, slay.)
  • -C command, --cmd command, --command command β€” use command to process files instead of rename. command can contain two instances of {} β€” the first gets replaced with the original filename, the second with the new one. if there are no {}'s at all, the old and new filename get appended to the command. πŸ”₯
  • -f, --force β€” remove existing destination files and never prompt the user. no questions, just vibes.
  • -g, --git β€” shortcut for --command "git mv" 🧚
  • -h, --help β€” print a summary of options and exit.
  • --no-stdin β€” disable reading of filenames from STDIN. use it when your shell has nullglob enabled, so you can be sure rename doesn't sit there waiting for input 😭 (the page literally spells it "Us it" β€” we're not fixing that, we're just telling you what it means.)
  • -i, --interactive β€” prompt whether to overwrite each destination file that already exists. if the response doesn't begin with y or Y, the file is skipped. consent culture fr fr πŸ’…
  • -l, --link-only β€” link files to the new names instead of renaming them. this keeps the original files. πŸŽ€
  • -n, --just-print, --dry-run β€” do everything but the actual renaming; instead, just print the name of each file that would be renamed. when used together with --verbose, it also prints names of backups (which may or may not be correct depending on previous renaming). πŸ‘€
  • -v, --verbose β€” print the name of each file before renaming it. main character energy.
  • -V method, --version-control=method β€” use method to determine backup file names. the method can also be given by the RENAME_VERSION_CONTROL environment variable (or if that's not set, the VERSION_CONTROL environment variable), which this option overrides. heads up: this option does not affect whether backup files are made β€” it affects only the name of any backup files that are made. ⭐

the value of method is like the GNU Emacs version-control variable; rename also recognizes synonyms that are more descriptive. the valid values are (unique abbreviations are accepted):

  • existing or nil β€” make numbered backups of files that already have them, otherwise simple backups. this is the default. πŸ‘‘
  • numbered or t β€” make numbered backups. the numbered backup file name for F is F.~N~ where N is the version number.
  • simple or never β€” make simple backups. the -B / --prefix, -Y / --basename-prefix, and -z / --suffix options specify the simple backup file name. if none of these options are given, then a simple backup suffix is used β€” either the value of the SIMPLE_BACKUP_SUFFIX environment variable if set, or ~ otherwise. 🌸
  • --version β€” print version information on standard output then exit successfully. πŸ’–
  • -Y prefix, --basename-prefix=prefix β€” use the simple method to determine backup file names (again: -V method / --version-control=method), and prefix prefix to the basename of a file name when generating its backup file name. for example, with -Y .del/ the simple backup file name for a/b/foo is a/b/.del/foo. πŸ¦‹
  • -z suffix, -S suffix, --suffix=suffix β€” use the simple method to determine backup file names (yes, -V method / --version-control=method again), and append suffix to a file name when generating its backup file name.
  • --shell-completion=shell, --shellcompletion=shell β€” generate shell code for parameter completion, for either bash or zsh. ✨

🌈 EXAMPLES 🌈

to rename all files matching *.bak and strip the extension, you might say:

rename 's/\.bak$//' *.bak

to translate uppercase names to lower, you'd use:

rename 'y/A-Z/a-z/' *

more examples, because we love a demo:

rename 's/\.flip$/.flop/' *     # rename *.flip to *.flop
rename s/flip/flop/ *           # rename *flip* to *flop*
rename 's/^s\.(.*)/$1.X/' *     # switch sccs filenames around
rename 's/$/.orig/' */*.[ch]    # add .orig to source files in */
rename 'y/A-Z/a-z/' *           # lowercase all filenames in .
rename 'y/A-Z/a-z/ if -B' *     # same, but just binaries!

or even:

rename chop *~                  # restore all ~ backup files

use --git when you're working within a GIT repo 🧚:

# rename _-separated filenames to camel-case, using git mv
rename --git 's/([a-z]+)_/\u\L$1/g' *.c

# or just renaming all the *.yml files to *.yaml
rename -g 's/\.yml$/.yaml/ *.yml

with the --command parameter you can make rename do other interesting stuff like:

# make thumbnails in PNG format of all JPEG file
rename 's/\.jpg/-thumb.png/' -C 'convert {} -resize 120x120 {}' *.jpg

πŸ“ ENVIRONMENT πŸ“

two environment variables are used: SIMPLE_BACKUP_SUFFIX and VERSION_CONTROL. peep "OPTIONS" for the details πŸ’œ

πŸ¦‹ SEE ALSO πŸ¦‹

mv(1) and perl(1)

πŸ’€ DIAGNOSTICS πŸ’€

if you give an invalid Perl expression you'll get a syntax error. (rude, but fair.)

πŸ‘‘ AUTHOR πŸ‘‘

Peder Stray <pederst@cpan.org>, original script from Larry Wall. absolute legends, both of them 🫢

πŸ™ˆ BUGS πŸ™ˆ

report any issues at <https://github.com/pstray/rename/issues>. bestie behavior honestly.


okay that's the whole page!! πŸ’– this one's perl v5.42.0, dated 2026-02-02, and it's the RENAME(1) page from the User Contributed Perl Documentation β€” go forth and rename things slayfully βœ¨πŸŽ€πŸ’…

πŸ“¦ where this page comes from