perl -e'($z = $_) =~ s/\s+/_/g, rename $_, $z or warn "$_: $!\n" for @ARGV' /some/directory/* /another/directory/*