Fix possible issue where folder is created as a file