LinuxCommandLibrary

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
Add extension
$ file-rename 's/$/.txt/' [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.

CAVEATS

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

SEE ALSO

mv(1), mmv(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community