mifi/lossless-cut · error · UserFacingError
No files found in folder
Error message
No files found in folder
What it means
Thrown by readDirRecursively() when, after recursively reading the directory and filtering to only real files (excluding directories and .DS_Store), the flat result array is empty. It guards downstream batch operations (e.g. recursive file opening) against being handed an empty file list. An empty folder, or one containing only subdirectories/junk, triggers it.
Source
Thrown at src/renderer/src/util.ts:393
const relevantFiles = files.filter((file) => /^vts_\d+_\d+\.vob$/i.test(file) && !/^vts_\d+_00\.vob$/i.test(file)); // skip menu
const ret = sortBy(relevantFiles).map((file) => join(videoTsPath, file));
if (ret.length === 0) throw new UserFacingError(i18n.t('No VTS vob files found in folder'));
return ret;
}
export async function readDirRecursively(dirPath: string) {
const files = await readdir(dirPath, { recursive: true });
const ret = (await pMap(files, async (path) => {
if (['.DS_Store'].includes(basename(path))) return [];
const absPath = join(dirPath, path);
const fileStat = await lstat(absPath); // readdir also returns directories...
if (!fileStat.isFile()) return [];
return [absPath];
}, { concurrency: 5 })).flat();
if (ret.length === 0) throw new UserFacingError(i18n.t('No files found in folder'));
return ret;
}
export function getImportProjectType(filePath: string) {
if (filePath.endsWith('Summary.txt')) return 'dv-analyzer-summary-txt';
const edlFormatForExtension = { csv: 'csv', pbf: 'pbf', edl: 'edl', cue: 'cue', xml: 'xmeml', fcpxml: 'fcpxml', otio: 'otio' } as const;
const matchingExt = Object.keys(edlFormatForExtension).find((ext) => filePath.toLowerCase().endsWith(`.${ext}`)) as keyof typeof edlFormatForExtension | undefined;
if (!matchingExt) return undefined;
return edlFormatForExtension[matchingExt];
}
export function getFileSize(format: FFprobeFormat) {
const fileSize = parseInt(format.size, 10);
if (Number.isNaN(fileSize)) return undefined;
return fileSize;
}
export const calcShouldShowWaveform = (zoomedDuration: number | undefined) => (zoomedDuration != null && zoomedDuration < ffmpegExtractWindow * 8);View on GitHub (pinned to 3b9a59c288)
Solutions
- Verify the selected folder actually contains media files at some depth using a file manager.
- Ensure the files are real files (not aliases/symlinks); copy actual media into the folder.
- If the folder genuinely has only subdirectories, place media files inside them or pick a different folder.
- Catch the error and inform the user 'no files were found in the selected folder'.
Defensive patterns
Strategy: validation
Validate before calling
import { readdir } from 'fs/promises';
export async function folderHasFiles(dirPath: string): Promise<boolean> {
const files = await readdir(dirPath, { recursive: true });
return files.length > 0;
}
if (!(await folderHasFiles(dir))) showError('The selected folder contains no files.'); Try / catch
try {
return await readDirRecursively(dirPath);
} catch (err) {
if (err instanceof UserFacingError && /No files found in folder/.test(err.message)) {
showError('The selected folder is empty.');
return [];
}
throw err;
} Prevention
- Confirm the folder contains real media files (not aliases/subdirs only) before opening.
- Filter the open-folder dialog to media extensions where possible.
- Handle the empty-folder case gracefully in the UI instead of surfacing a raw error.
When it happens
Trigger: Calling readDirRecursively(dirPath) on a folder that has no files at any depth (only subdirectories); a folder whose only files are .DS_Store (explicitly filtered out); a folder containing only symlinks/directories that fail the isFile() check; an empty directory.
Common situations: User picks an empty folder or one with only nested empty subfolders in the recursive-open dialog; macOS folders littered solely with .DS_Store; a folder of aliases/shortcuts rather than real media; pointing at a system directory with no regular files.
Related errors
- No VTS vob files found in folder
- No rows found
- Invalid start or end value. Must contain a number of seconds
- Invalid EDL data found
- Less than 2 frames found
AI-assisted analysis of mifi/lossless-cut@3b9a59c288 (2026-08-12).
Data as JSON: /api/errors/c06585ca384f3e57.
Report an issue: GitHub.