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

Re: batch renaming for filenames with space



On Sunday 27 July 2003 12:45, Micha Feigin wrote:
> 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
you can also add to the script something like:

export IFS=$'\n'
for file in `ls copy*`; do...

but remember to change it back to the usual value ($' \t\n') right after this.

Bye
-- 
Haim



Reply to: