Fix escaping issues when dir contains '%' or other special characters.