Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   Shell batch rename command/script (http://www.greenguysboard.com/board/showthread.php?t=28449)

CelticTiger 2006-01-30 05:17 AM

Shell batch rename command/script
 
I'm hoping someone can help me figure out how to batch rename files recursively thru a directory on our server......ie I'd like to rename all files starting with "thumb_" to "tn_" leaving the remainder of the file name intact so that thumb_pic01.jpg would be renamed tn_pic01.jpg

Any help is greatly appreciated :)

swedguy 2006-01-30 05:36 AM

find . -name "thumb_*.jpg" -exec echo "mv '{}' '{}'" \; | sed 's/thumb_/tn_/2' | /bin/sh

CelticTiger 2006-01-30 05:55 AM

Nice one swedeguy Thanks alot! |thumb

Servhot 2006-01-30 06:44 AM

Also MMV is a very nice tool for the shell which can not rename only, you also can move files, folders etc.

rtv 2006-01-31 05:18 PM

Quote:

Originally Posted by swedguy
find . -name "thumb_*.jpg" -exec echo "mv '{}' '{}'" \; | sed 's/thumb_/tn_/2' | /bin/sh


You're genius! I wish I knew this earlier!


All times are GMT -4. The time now is 09:11 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc