Bulk Rename Files

Last modified: 
Monday, March 30th, 2015

Rename Multiple Files of the Same Name but Different Extension

for i in old_name.*; do mv "$i" "new_name.${i##*.}"; done

The Drupal module "mymodule" has multiple files with the name "mymodule" but differing extensions.

ls -1
mymodule.css
mymodule.inc
mymodule.info
mymodule.js
mymodule.module

We want to rename all of these files to "yourmodule" while keeping the various extensions intact.

for i in mymodule.*; do mv "$i" "yourmodule.${i##*.}"; done

ls -1
yourmodule.css
yourmodule.inc
yourmodule.info
yourmodule.js

Reference

http://stackoverflow.com/a/15585566/265901


The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.