SubtitleEdit/subtitleedit · error · FileNotFoundException
Subtitle file not found: {filePath}
Error message
Subtitle file not found: {filePath} What it means
Thrown by SubtitleInfoGatherer.Gather (the seconv info command) when the supplied path does not exist on disk. It is a FileNotFoundException, so the message plus the file name are available on the exception.
Source
Thrown at src/seconv/Core/SubtitleInfoGatherer.cs:17
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
namespace SeConv.Core;
/// <summary>
/// Loads a subtitle file and produces a flat <see cref="SubtitleInfo"/> record:
/// path, size, detected format, encoding, paragraph count, total/first/last
/// timecodes, and detected language. Used by <c>seconv info</c>.
/// </summary>
internal static class SubtitleInfoGatherer
{
public static SubtitleInfo Gather(string filePath)
{
if (!File.Exists(filePath))
{
throw new FileNotFoundException($"Subtitle file not found: {filePath}");
}
var fileSize = new FileInfo(filePath).Length;
// Detect encoding before format so the displayed encoding is the *source*
// encoding (not whatever the format used internally).
var encoding = LanguageAutoDetect.GetEncodingFromFile(filePath);
var (subtitle, format) = LibSEIntegration.LoadSubtitleWithFormat(filePath);
long? firstStartMs = null;
long? lastEndMs = null;
if (subtitle.Paragraphs.Count > 0)
{
firstStartMs = (long)subtitle.Paragraphs[0].StartTime.TotalMilliseconds;
lastEndMs = (long)subtitle.Paragraphs[^1].EndTime.TotalMilliseconds;
}
View on GitHub (pinned to 17a9f07487)
Solutions
- Verify the path with ls/dir before running; use an absolute path.
- Check the shell's working directory for relative paths.
- Quote paths containing spaces or special characters.
- If using a glob, confirm it expanded to real files.
Example fix
// before seconv info movei.srt // typo // after seconv info movie.srt
Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists(filePath))
throw new FileNotFoundException($"Subtitle file not found: {filePath}", filePath); Type guard
static bool IsReadableFile(string path) => File.Exists(path);
Try / catch
try { var info = SubtitleInfoGatherer.Gather(path); }
catch (FileNotFoundException ex) { Console.Error.WriteLine(ex.Message); } Prevention
- Use absolute paths in scripts.
- Validate inputs with File.Exists before calling Gather.
- Confirm glob patterns actually expanded before forwarding them.
When it happens
Trigger: Calling seconv info <path> (or SubtitleInfoGatherer.Gather directly) where File.Exists(filePath) is false.
Common situations: Typo in the path, relative path resolved against the wrong working directory, file deleted between glob expansion and processing, or a glob pattern that matched nothing and was passed literally.
Related errors
- Could not find a free output filename for: {baseName}
- Failed to start tesseract process.
- File not found
- llama-server executable not found - please download llama.cp
- llama.cpp model not found - please download a model first.
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/e1182e25d77f5b7c.
Report an issue: GitHub.