// Name: Select Folder and Files Demo // Description: Pick a folder, then select multiple files within it. // Author: JosXa // GitHub: JosXa import "@johnlindquist/kit" const folderPath = await selectFolder("Select a folder to pick files from") if (!folderPath) exit() const pattern = path.join(folderPath, "**/*") const files = await globby(pattern) if (!files.length) { await div(md(`No files found in: - ${folderPath}`)) exit() } const choices = files.map(f => ({ name: path.relative(folderPath, f), description: f, value: f, })) const selected = await select<string[]>( { placeholder: "Select one or more files (Tab to multi-select)", enter: "Confirm Selection", }, choices ) await div( md( `# Selected Files (${selected.length}) ${selected.map(f => `- ${path.relative(folderPath, f)}`).join("\n")}` ) )