[Gllug] Mass renaming of files

Richard Jones rich at annexia.org
Wed May 7 16:46:48 UTC 2003


On Wed, May 07, 2003 at 05:32:42PM +0100, 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 :
> 
> b) Rename these files to replace the : with a - or possibly remove the
> colon altogether.

Sounds like another shortest script challenge to me! Hmmmm ... I came
up with the following rather crufy solution. It doesn't work if filenames
contain double quotes.

find -name '*:*' | perl -e 'while(<>){chomp;print "mv \"$_\" "; $_ =~ tr/:/-/; print "\"$_\"\n"}' | less

Replace 'less' with 'sh' when you want to run the commands.

Rich.

-- 
Richard Jones, Red Hat Inc. (London) and Merjis Ltd. http://www.merjis.com/
http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj
PTHRLIB is a library for writing small, efficient and fast servers in C.
HTTP, CGI, DBI, lightweight threads: http://www.annexia.org/freeware/pthrlib/


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




More information about the GLLUG mailing list