How to get rid of spaces in file names

If you want to get rid of the spaces in the file/directory names then just look at this simple script:

#!/bin/bash

ls | grep "\ " | while read item
do
  new=`echo ${item} | tr [:blank:] _`
  old=${item}
  mv "${old}" ${new}
done

Above mentioned script works in current directory for files and directories.