Rename is a simple command-line tool which lets you easily rename your files using regular expressions (RegEx).

As we will see in the examples below, the syntax is pretty straightforward.

Example 1:


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

This command will loop through a chosen directory and translates uppercase filenames to lowercase.

Example 2:


rename s/'^'/'PREFIX'/ *

This code is used to add a prefix to every filename.

Example 3:


rename s/"X"/"Y"/g *

You can use this command to replace all occurrences of the the string X with Y in every filename.

NOTE: Rename is included by default in almost all Linux distributions.

Comments