SubtitleEdit/subtitleedit · error · InvalidOperationException
Output folder is not set
Error message
Output folder is not set
What it means
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.
Source
Thrown at src/ui/Features/Tools/BatchConvert/BatchConverter.cs:2915
var kept = subtitle.Paragraphs
.Where((_, idx) => !removed.Contains(idx))
.ToList();
subtitle.Paragraphs.Clear();
subtitle.Paragraphs.AddRange(kept);
subtitle.Renumber();
return subtitle;
}
private string MakeOutputFileName(BatchConvertItem item, string extension)
{
var outputFolder = _config.SaveInSourceFolder || string.IsNullOrEmpty(_config.OutputFolder)
? Path.GetDirectoryName(item.FileName)
: _config.OutputFolder;
if (string.IsNullOrEmpty(outputFolder))
{
throw new InvalidOperationException("Output folder is not set");
}
var fileName = Path.GetFileNameWithoutExtension(item.FileName);
if (!string.IsNullOrEmpty(item.OutputFileName))
{
fileName = Path.GetFileNameWithoutExtension(item.OutputFileName);
}
var targetExtension = extension;
if (!string.IsNullOrEmpty(item.LanguageCode))
{
if (Se.Settings.Tools.BatchConvert.LanguagePostFix == Se.Language.General.TwoLetterLanguageCode)
{
var code = item.LanguageCode;
if (code.Length == 3)
{
code = Iso639Dash2LanguageCode.GetTwoLetterCodeFromThreeLetterCode(code);View on GitHub (pinned to 17a9f07487)
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.
Example fix
// before
var outputFolder = _config.SaveInSourceFolder || string.IsNullOrEmpty(_config.OutputFolder)
? Path.GetDirectoryName(item.FileName)
: _config.OutputFolder;
if (string.IsNullOrEmpty(outputFolder))
{
throw new InvalidOperationException("Output folder is not set");
}
// after — fall back to a sensible default and give a precise message
var outputFolder = _config.SaveInSourceFolder || string.IsNullOrEmpty(_config.OutputFolder)
? Path.GetDirectoryName(item.FileName)
: _config.OutputFolder;
if (string.IsNullOrEmpty(outputFolder))
{
throw new InvalidOperationException(
$"Output folder is not set for '{item.FileName}'. " +
$"SaveInSourceFolder={_config.SaveInSourceFolder}, OutputFolder='{_config.OutputFolder}'. " +
"Set an output folder in Batch Convert settings or ensure the input file has a directory path.");
} Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight check before batch conversion
foreach (var item in items)
{
var dir = _config.SaveInSourceFolder || string.IsNullOrEmpty(_config.OutputFolder)
? Path.GetDirectoryName(item.FileName)
: _config.OutputFolder;
if (string.IsNullOrEmpty(dir))
throw new InvalidOperationException($"Cannot resolve output folder for '{item.FileName}'. Set OutputFolder or ensure file has a directory path.");
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Color '{colorName}' not found in SKColors.
- Dvd language {code} not found!
- Problem accessing RIFF file {FileName}
- Problem reading data in file {FileName}
- Model file not found.
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/a5e069bfe1685b6a.
Report an issue: GitHub.