Make sure output directory exists
Added parametr whether escape command attributes.