Generate directory structure for output file if needed.