Create the intermediate directory if required