Ians Ramblings Ian's ramblings, daily, ish

13Jan/100

Recursively Rename Files Linux

I was just doing this today and thought I would post the bash script I wrote to do the job. This particular example finds all jpeg files recursively and renames them to .jpg but you could just change the .jpeg part to anything and / or the .jpg part.

You just have to paste this into a .sh file and run it with sh filename.sh or set it's executable bit and run it with ./filename.sh

#!/bin/bash

find ./ -type f -name "*.jpeg" | while read FILEdonewname=`echo $FILE | sed s/\.jpeg$/\.jpg/`echo "renaming $FILE to $newname"mv "$FILE" "$newname"done
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.

7 visitors online now
6 guests, 1 members
Max visitors today: 7 at 01:35 pm UTC
This month: 8 at 03-09-2010 10:50 am UTC
This year: 21 at 02-25-2010 11:24 am UTC
All time: 21 at 02-25-2010 11:24 am UTC