Sanitize directory input. (Trailing slashes caused new file detection to fail.)