{"record":{"id":"a5e069bfe1685b6a","repo":"SubtitleEdit/subtitleedit","slug":"output-folder-is-not-set","errorCode":null,"errorMessage":"Output folder is not set","messagePattern":"Output folder is not set","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/ui/Features/Tools/BatchConvert/BatchConverter.cs","lineNumber":2915,"sourceCode":"\n        var kept = subtitle.Paragraphs\n            .Where((_, idx) => !removed.Contains(idx))\n            .ToList();\n        subtitle.Paragraphs.Clear();\n        subtitle.Paragraphs.AddRange(kept);\n        subtitle.Renumber();\n\n        return subtitle;\n    }\n\n    private string MakeOutputFileName(BatchConvertItem item, string extension)\n    {\n        var outputFolder = _config.SaveInSourceFolder || string.IsNullOrEmpty(_config.OutputFolder)\n            ? Path.GetDirectoryName(item.FileName)\n            : _config.OutputFolder;\n        if (string.IsNullOrEmpty(outputFolder))\n        {\n            throw new InvalidOperationException(\"Output folder is not set\");\n        }\n\n        var fileName = Path.GetFileNameWithoutExtension(item.FileName);\n        if (!string.IsNullOrEmpty(item.OutputFileName))\n        {\n            fileName = Path.GetFileNameWithoutExtension(item.OutputFileName);\n        }\n\n        var targetExtension = extension;\n\n        if (!string.IsNullOrEmpty(item.LanguageCode))\n        {\n            if (Se.Settings.Tools.BatchConvert.LanguagePostFix == Se.Language.General.TwoLetterLanguageCode)\n            {\n                var code = item.LanguageCode;\n                if (code.Length == 3)\n                {\n                    code = Iso639Dash2LanguageCode.GetTwoLetterCodeFromThreeLetterCode(code);","sourceCodeStart":2897,"sourceCodeEnd":2933,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Features/Tools/BatchConvert/BatchConverter.cs#L2897-L2933","documentation":"Thrown by MakeOutputFileName when it cannot resolve a non-empty output directory. The folder is derived either from the source file's directory (when SaveInSourceFolder is true or OutputFolder is empty) or from _config.OutputFolder. Path.GetDirectoryName returns null for root-level paths like \"C:\\\" or empty strings, and if OutputFolder is also empty the method has nowhere to write.","triggerScenarios":"SaveInSourceFolder is true (or OutputFolder is empty) AND Path.GetDirectoryName(item.FileName) returns null — this happens when item.FileName is a root path like \"C:\" or \"\\\". Alternatively, SaveInSourceFolder is false and _config.OutputFolder is null or whitespace.","commonSituations":"A file dragged from a root drive letter without a path separator; a UNC path that GetDirectoryName mishandles; the batch convert OutputFolder setting was cleared in configuration; a programmatic batch run where item.FileName was set to a bare filename without a directory component.","solutions":["Ensure _config.OutputFolder is set to a valid absolute path before batch conversion if not saving to source folder.","Validate that each BatchConvertItem.FileName contains a directory component (not a bare filename or root path) before starting conversion.","If SaveInSourceFolder is false, verify the OutputFolder setting in the BatchConvert configuration dialog is populated.","Add a pre-flight check on all items before the batch loop to surface the problematic file name early."],"exampleFix":"// before\nvar outputFolder = _config.SaveInSourceFolder || string.IsNullOrEmpty(_config.OutputFolder)\n    ? Path.GetDirectoryName(item.FileName)\n    : _config.OutputFolder;\nif (string.IsNullOrEmpty(outputFolder))\n{\n    throw new InvalidOperationException(\"Output folder is not set\");\n}\n\n// after — fall back to a sensible default and give a precise message\nvar outputFolder = _config.SaveInSourceFolder || string.IsNullOrEmpty(_config.OutputFolder)\n    ? Path.GetDirectoryName(item.FileName)\n    : _config.OutputFolder;\nif (string.IsNullOrEmpty(outputFolder))\n{\n    throw new InvalidOperationException(\n        $\"Output folder is not set for '{item.FileName}'. \" +\n        $\"SaveInSourceFolder={_config.SaveInSourceFolder}, OutputFolder='{_config.OutputFolder}'. \" +\n        \"Set an output folder in Batch Convert settings or ensure the input file has a directory path.\");\n}","handlingStrategy":"validation","validationCode":"// Pre-flight check before batch conversion\nforeach (var item in items)\n{\n    var dir = _config.SaveInSourceFolder || string.IsNullOrEmpty(_config.OutputFolder)\n        ? Path.GetDirectoryName(item.FileName)\n        : _config.OutputFolder;\n    if (string.IsNullOrEmpty(dir))\n        throw new InvalidOperationException($\"Cannot resolve output folder for '{item.FileName}'. Set OutputFolder or ensure file has a directory path.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set _config.OutputFolder to a valid absolute path before batch processing.","Validate all BatchConvertItem.FileName entries have a directory component before starting the batch.","Use the folder picker dialog for OutputFolder rather than accepting manual input without validation."],"tags":["io","config","batch-convert","path-resolution"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}