Mass Renaming Files

From Redbrick Wiki
Revision as of 01:43, 20 April 2007 by Receive (talk | contribs)
Jump to navigation Jump to search

Mass Renaming Files

Introduction

Mass renaming of files can vary depending on what platform and system you're on. If you're on Unix, and more specifically Unix, the following techniques should be available to you.

If you're using RedBrick then both mmv and rename are available to you.

In this scenario, we are going to try and rename all .php files in the current directory so they have a .gif extension

WARNING: always backup your files


Using mmv

mmv '*.php' '#1.gif'


Using rename

rename 's/\.php$/.gif/' *.php


In the Bash shell

for file in *.php; do mv "$file" "${file%.php}.gif"; done