On Fri, Feb 13, 2004 at 08:58:56AM -0800, Brian wrote:
> Hi,
> What is an easy way to rename a lot of files and 
> directories that were moved from Windows?  They 
> have (, spaces, ^, $, etc in them.  `ls |sed s/\ 
> //g` removes spaces, but then I don't how to take 
> each one and move the file/dir correctly.
> 

I'm not sure that there's an easy way, as such, however,
bash scripting is the method I'd be inclined to take.

The gotcha for bash scripting is that the IFS (internal
field separator) usually includes a space character,
so you might need to change it to just a linefeed to
get scripts to work properly on this.  That might be
considered to be a bug in bash.

eg: (untested!)

IFS='
'

for i in $(ls) ; do echo cp  $i /newdir/$(echo $i | sed s/\ \/_/g) ; done
                   ^^^^^ 

Obviously you'd need to put whatever chars into the
sed script you wanted to remove/replace.  Personally, I'd
suggest putting an underscore or something in instead of
the space or other char.

When the script is correct, then remove the echo with 
carets underneath it, execute.

If you're really brave you could use mv instead of cp.

-- 
Mark Kent


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to