Make sure the directory exists before trying to move the file.