Sort files into folders by extension

cd /path/to/dir

shopt -s nullglob
for file in *.{avi,rmvb,mkv}
do
  directory="${file%.*}"             # remove file extension 
  directory="${directory//_/ }"      # replace underscores with spaces

  darr=( $directory )
  darr="${darr[@]^}"                 # capitalize the directory name

  echo mkdir -p -- "$darr"           # create the directory; 
  echo mv -b -- "$file" "$darr"      # move the file to the directory
  echo
done