Fix issue with spaces in file/dirname when auto-detecting subdir