make sure directories exist before adding files to them