Rename in mass

GNU/Linux
prename is a utility developed in Perl by Larry Wall (creator of the Perl language) and improved by Robin Barker, which allows you to rename in masses. prename finds all files whose name matches a pattern specified (REGEXP). This utility is part of the perl package in Debian GNU/Linux.

Synopsis

$ $ prename [-v] [-n] [-f] REGEXP files

where:

-v,--verbose: displays the name of the files that were successfully renamed
-n,--noact: simulates the operation
-f,-force: overwrite existing files	

REGEXP: is a PCRE compatible pattern

Examples

Deletes .bak extension for every file under the current DIR

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

Make to lowercase the name of all files of the current DIR

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

Find all files whose name contains more than one dash and replace them with single one

$ rename 's/-{2,}/-/g' *

Recommended reading

-man prename

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.