[Gllug] Mass renaming of files

Alan Peery peery at io.com
Fri May 9 09:56:01 UTC 2003


Richard Cohen wrote:

>#! /bin/bash
># THIS IS UNTESTED - MAKE SURE IT WORKS BEFORE RUNNING ON IMPORTANT
># FILES
>for i in $(find <dirname> -type f -name *:*)
>do
>	newname=${i//:/-}
>	#newname=${i//:/ } - this should work, but I'm not 100% sure
>	#newname=${i//:} - to just remove :
>	echo mv $i "$newname"
>	#mv $i $newname - use this line when you're sure the mv commands look right
>done
>  
>
I think the above will fail if any of the directory names have ":" in 
them.  I think this could be handled nicely by running this script with 
a "-type d" in the find first, and then as above.

Alan




-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list