Batch renaming with the rename utility

I was in a situation recently where I had a directory full of .whl files I wanted to rename to .zip files. Fortunately, there is the rename utility, which appears to be a thin Perl wrapper.

Given the directory:

In addition, I needed to chop off everything that came after the first -, e.g.:

asn1crypto.zip
cffi.zip
cryptography.zip
...

We can use the following rename command:

rename -n 's/([\w]+)-.*/$1.zip/' *.whl

Where:

-n, -nono
        No action: print names of files to be renamed, but
        don't rename.

Et voilĂ !

Date: <2017-10-01 Sun>

Author: keith

Created: 2017-10-01 Sun 17:55

Validate