{"record":{"id":"c06585ca384f3e57","repo":"mifi/lossless-cut","slug":"no-files-found-in-folder","errorCode":null,"errorMessage":"No files found in folder","messagePattern":"No files found in folder","errorType":"exception","errorClass":"UserFacingError","httpStatus":null,"severity":"error","filePath":"src/renderer/src/util.ts","lineNumber":393,"sourceCode":"  const relevantFiles = files.filter((file) => /^vts_\\d+_\\d+\\.vob$/i.test(file) && !/^vts_\\d+_00\\.vob$/i.test(file)); // skip menu\n  const ret = sortBy(relevantFiles).map((file) => join(videoTsPath, file));\n  if (ret.length === 0) throw new UserFacingError(i18n.t('No VTS vob files found in folder'));\n  return ret;\n}\n\nexport async function readDirRecursively(dirPath: string) {\n  const files = await readdir(dirPath, { recursive: true });\n  const ret = (await pMap(files, async (path) => {\n    if (['.DS_Store'].includes(basename(path))) return [];\n\n    const absPath = join(dirPath, path);\n    const fileStat = await lstat(absPath); // readdir also returns directories...\n    if (!fileStat.isFile()) return [];\n\n    return [absPath];\n  }, { concurrency: 5 })).flat();\n\n  if (ret.length === 0) throw new UserFacingError(i18n.t('No files found in folder'));\n  return ret;\n}\n\nexport function getImportProjectType(filePath: string) {\n  if (filePath.endsWith('Summary.txt')) return 'dv-analyzer-summary-txt';\n  const edlFormatForExtension = { csv: 'csv', pbf: 'pbf', edl: 'edl', cue: 'cue', xml: 'xmeml', fcpxml: 'fcpxml', otio: 'otio' } as const;\n  const matchingExt = Object.keys(edlFormatForExtension).find((ext) => filePath.toLowerCase().endsWith(`.${ext}`)) as keyof typeof edlFormatForExtension | undefined;\n  if (!matchingExt) return undefined;\n  return edlFormatForExtension[matchingExt];\n}\n\nexport function getFileSize(format: FFprobeFormat) {\n  const fileSize = parseInt(format.size, 10);\n  if (Number.isNaN(fileSize)) return undefined;\n  return fileSize;\n}\n\nexport const calcShouldShowWaveform = (zoomedDuration: number | undefined) => (zoomedDuration != null && zoomedDuration < ffmpegExtractWindow * 8);","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/mifi/lossless-cut/blob/3b9a59c288bf6e11076b583c932cfa48ddab3b02/src/renderer/src/util.ts#L375-L411","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { readdir } from 'fs/promises';\nexport async function folderHasFiles(dirPath: string): Promise<boolean> {\n  const files = await readdir(dirPath, { recursive: true });\n  return files.length > 0;\n}\nif (!(await folderHasFiles(dir))) showError('The selected folder contains no files.');","typeGuard":null,"tryCatchPattern":"try {\n  return await readDirRecursively(dirPath);\n} catch (err) {\n  if (err instanceof UserFacingError && /No files found in folder/.test(err.message)) {\n    showError('The selected folder is empty.');\n    return [];\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["io","folder","recursive","filesystem","validation"],"backgroundTag":null,"analyzedSha":"3b9a59c288bf6e11076b583c932cfa48ddab3b02","analyzedAt":"2026-08-12T20:54:25.651Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}