Thanks, I like the python version
Carson
---------- Original Message ----------------------------------
From: Ronan Heffernan <ronan@iotcorp.com>
Reply-To: slug@nks.net
Date: Thu, 11 Jul 2002 06:38:59 -0400
>Carson Wilcox wrote:
>> I need to remove the spaces from all the file names in a
directory.
>>
>> The command:
>> find -type f | tr ' ' '-'
>>
>> Replaces all the spaces with a '-' and prints it to stdout,
>> however I can't figure out how to actually rename the file.
>>
>> I thought that
>> find -type f | tr ' ' '-' | xargs cp
>>
>> might work, but that barfed all over it self, any ideas
>> appreciated.
>>
>> Thanks,
>> Carson
>
>
>Here is a python script that will do what you want (actually,
this will
>also change spaces to dashes for directoryies also; if this is
>undesireable, add an "if (isfile(i)):" clause before the rename):
>
>#!/usr/bin/env python
>import os
>files=os.listdir(".")
>for i in files:
> newname=i.replace(" ","-")
> os.rename(i,newname)
>
>
>
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 13:39:33 EDT