function getFileOutputPath(pattern, context) {
  let filename = pattern;
  const matches = pattern.match(/%%([a-z]+)%%/gi) || [];
  for (const match of matches) {
    const name = match.slice(2, -2).toLowerCase();
    const value = context[name] || 'unknown';
    const sanitizedValue = value.replace(/[^a-z0-9]+/gi, '_').replace(/^_/, '');
    filename = filename.replace(match, sanitizedValue);
  }

  return filename;
}
@param {string} pattern
@param {Record<string, string>} context