#!/bin/bash while [ "$1" != "" ] ; do out=`echo $1` #now we convert all spaces to "_" out=`echo ${out//" "/"_"}` mv "$1" "$out" shift done