[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

batch renaming for filenames with space



I am trying to do a batch rename for a bunch of files with spaces in the
name (in order to remove the spaces actually). I tried to use bash's for
.. in command but it splits up the lines on spaces and not on line ends.
Any ideas?

The files are named "Copy of ..." and I want to drop the Copy of part.
I tried to do
for file in `ls -1`; do 
  cp $file `echo -n "$file" | sed 's/Copy of \(.*\)/\1/'`
done

but like I said the file name is split into three matches, one for
"Copy", one for "of" and one for the rest (no more spaces).

For the moment I am ignoring the option for other files in the directory
since that is much easier to handle.

Thanks



Reply to: