1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-06-08 23:06:00 +02:00
tldr/pages/linux/perl-rename.md
Managor 5305776d45
*: capitalize the first letter after "Note:" (#16226)
Co-authored-by: Machiavelli <145562237+MachiavelliII@users.noreply.github.com>
2025-05-04 05:15:17 +03:00

752 B

rename

Rename multiple files. Note: This page refers to the command from the perl-rename Arch Linux package. More information: https://manned.org/rename.

  • Rename files using a Perl Common Regular Expression (substitute 'foo' with 'bar' wherever found):

rename {{'s/foo/bar/'}} {{*}}

  • Dry-run - display which renames would occur without performing them:

rename {{[-n|--no-act]}} {{'s/foo/bar/'}} {{*}}

  • Force renaming even if the operation would remove existing destination files:

rename -f {{'s/foo/bar/'}} {{*}}

  • Convert filenames to lower case (use -f in case-insensitive filesystems to prevent "already exists" errors):

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

  • Replace whitespace with underscores:

rename 's/\s+/_/g' {{*}}