Last active
June 20, 2024 16:17
-
-
Save burkybang/f2f3ace262b554a3c6195170f0e36563 to your computer and use it in GitHub Desktop.
ScriptKit script: Drag and drop files onto UI, and all file names will be copied
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Name: Copy File Paths | |
import '@johnlindquist/kit'; | |
interface ScriptKitFile { | |
lastModified: number; | |
lastModifiedDate: string; | |
name: string; | |
path: string; | |
size: number; | |
type: string; | |
webkitRelativePath: string; | |
} | |
const files = await drop(); | |
const isFiles = (input: unknown): input is ScriptKitFile[] => | |
Array.isArray(input) && input.every(value => value && typeof value === 'object' && 'path' in value && typeof value.path === 'string'); | |
if (isFiles(files)) { | |
const whatToCopy: string = await arg('What to Copy', [ | |
'Paths', | |
'Names', | |
]); | |
const fileProp: string = whatToCopy.toLowerCase().slice(0, -1); | |
await copy(files.map(file => file[fileProp]).join('\n')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment