Select a Path

Select a Path

// Name: Select a Path
import "@johnlindquist/kit"
let filePath = await path()
await div(md(`You selected ${filePath}`))

Open select-a-path in Script Kit

Select a Path with Options

// Name: Select a Path with Options
import "@johnlindquist/kit"
await path({
hint: `Select a path containing JS files`,
onlyDirs: true,
onChoiceFocus: async (input, { focused }) => {
let focusedPath = focused.value
try {
let files = await readdir(focusedPath)
let hasJS = files.find(f => f.endsWith(".js"))
setPreview(
md(
`${
hasJS ? "✅ Found" : "🔴 Didn't find"
} JS files`
)
)
} catch (error) {
log(error)
}
},
})

Open select-a-path-with-options in Script Kit

Drag and Drop

// Name: Drop Example
import "@johnlindquist/kit"
// Note: Dropping one or more files returns an array of file information
// Dropping text or an image from the browser returns a string
let fileInfos = await drop()
let filePaths = fileInfos.map(f => f.path).join(",")
await div(md(filePaths))

Open drop-example in Script Kit

Select from Finder Prompts

// Name: Select from Finder Prompt
import "@johnlindquist/kit"
let filePath = await selectFile()
let folderPath = await selectFolder()
await div(md(`You selected ${filePath} and ${folderPath}`))

Open select-from-finder-prompt in Script Kit

Discuss Post