Clear Downloads Folder

// Name: Clear Downloads Folder
// Description: Lists files and folders within your downloads folder and asks which items you want to remove
// Author: Ricardo Gonçalves Bassete
import "@johnlindquist/kit"
const downloadsFolder = home('Downloads')
const items = await readdir(downloadsFolder)
const itemsToRemove: string[] = await select({
placeholder: 'Select the items you want to remove',
alwaysOnTop: true,
strict: true,
}, items)
const wishToRemove = await arg({
placeholder: 'This will remove all selected items, do you want to continue?',
choices: [
{ name: 'Yes', value: true },
{ name: 'No', value: false }
],
strict: true
})
if(wishToRemove) {
itemsToRemove.forEach(item => {
const itemPath = path.resolve(downloadsFolder, item)
remove(itemPath)
})
}