LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

file-rename

Perl regex-based file renaming

TLDR

Rename using Perl expression
$ file-rename 's/old/new/' [files]
copy
Rename to lowercase
$ file-rename 'y/A-Z/a-z/' [files]
copy
Dry run to preview changes
$ file-rename -n 's/pattern/replacement/' [files]
copy
Replace spaces with underscores
$ file-rename 's/ /_/g' [files]
copy
Add prefix to files
$ file-rename 's/^/prefix_/' [files]
copy
Change file extension
$ file-rename 's/\.jpeg$/.jpg/' [*.jpeg]
copy
Remove numbering prefix from files
$ file-rename 's/^\d+_//' [files]
copy

SYNOPSIS

file-rename [options] expression [files...]

DESCRIPTION

file-rename (also known as rename or prename) renames multiple files using Perl regular expressions, providing powerful pattern-based transformation capabilities. Unlike simple mv operations, it can apply complex substitutions, case conversions, and pattern matching across multiple filenames simultaneously.The tool supports the full Perl regex syntax including capture groups, look-ahead/look-behind assertions, and transliteration operations. Common uses include batch renaming, removing or replacing characters, changing file extensions, and standardizing filename formats.file-rename's dry-run mode (-n) allows preview of changes before execution, preventing accidental destructive operations. The force flag (-f) enables overwriting existing files when name collisions occur.

PARAMETERS

-n, --no-act

Dry run, show what would happen.
-v, --verbose
Print names of files renamed.
-f, --force
Overwrite existing files.
-0, --null
Expect null-terminated input from stdin (for use with find -print0).
-d, --filename
Rename only the filename component, not the directory part.
-e expression
Apply expression to filename. Multiple -e options can be chained.

INSTALL

nix profile install nixpkgs#file-rename
copy

CAVEATS

Multiple implementations of rename exist. This documents the Perl version (prename), not the util-linux version.

SEE ALSO

rename(1), mv(1), mmv(1), find(1), perl(1), sed(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid