Update script to handle removing whitespace from arbitrary paths

closes #4396