Skip to content

Instantly share code, notes, and snippets.

@burkybang
Last active June 20, 2024 16:17
Show Gist options
  • Save burkybang/f2f3ace262b554a3c6195170f0e36563 to your computer and use it in GitHub Desktop.
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
// 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