Don't generated file names with spaces, and replace multiple consecutive underscores with a single underscore. Refs #1705