[Gllug] Mass renaming of files

Richard Cohen richard at vmlinuz.org
Wed May 7 16:37:04 UTC 2003


On Wed, 7 May 2003, Simon Morris wrote:

> Hi GLLUGers,
>
> I have a IRIX server at work providing file access for UNIX,Linux, MAC
> OS 9 and various versions of Windows.
>
> We have a problem where there are many filenames including colons :
>
> Theses files are readable using Macs and UNIX OS's but the Windows
> machines won't copy them from the server.
>
> What is the best way to:
>
> a) Find all the files under a certain directory where the filename
> includes a :

"find <dirname> -type f -name *:*"

> b) Rename these files to replace the : with a - or possibly remove the
> colon altogether.

#! /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

> Thanks

Cheers
Richard


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




More information about the GLLUG mailing list