Selecting Files

Selecting Files

You can get files into your scripts in many different ways.

Currently Selected Files

One of the most convenient is to just run a script on the currently selected files in Finder:

// Always returns a string
let filePath = await getSelectedFile()
// If multiple files selected, split by "\n"
if (filePath.includes("\n")) {
let filePaths = filePath.split("\n")
}

Prompt for Selection

Otherwise, you can prompt to select a file:

// Open the Finder prompt for file selection
let filePath = await selectFile()
// Open the Finder prompt for folder selection
let folderPath = await selectFolder()

Drag and Drop

// Kit.app opens a UI where you can drop files/text/links
// Dropping files will result in an Array of files object
let dropResult = await drop()
devTools(dropResult)
Discuss Post