import_folder
Import media files from a specified folder into the current Adobe Premiere Pro project, optionally organizing them into a named bin and including subfolders recursively.
Instructions
Imports all media files from a folder into the current Premiere Pro project.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| binName | No | The name of the bin to import the media into | |
| folderPath | Yes | The absolute path to the folder containing media files | |
| recursive | No | Whether to import from subfolders recursively |
Implementation Reference
- src/tools/index.ts:836-890 (handler)The handler function for the 'import_folder' tool. It constructs and executes an ExtendScript via the bridge to import media files from the specified folder into the Premiere Pro project, supporting recursive import and targeting a specific bin.private async importFolder(folderPath: string, binName?: string, recursive = false): Promise<any> { const script = ` try { var folder = new Folder("${folderPath}"); var importedItems = []; var errors = []; function importFiles(dir, targetBin) { var files = dir.getFiles(); for (var i = 0; i < files.length; i++) { var file = files[i]; if (file instanceof File) { try { var item = targetBin.importFiles([file.fsName]); if (item && item.length > 0) { importedItems.push({ name: file.name, path: file.fsName, id: item[0].nodeId }); } } catch (e) { errors.push({ file: file.name, error: e.toString() }); } } else if (file instanceof Folder && ${recursive}) { importFiles(file, targetBin); } } } var targetBin = app.project.rootItem; ${binName ? `targetBin = app.project.rootItem.children["${binName}"] || app.project.rootItem;` : ''} importFiles(folder, targetBin); JSON.stringify({ success: true, importedItems: importedItems, errors: errors, totalImported: importedItems.length, totalErrors: errors.length }); } catch (e) { JSON.stringify({ success: false, error: e.toString() }); } `; return await this.bridge.executeScript(script); }
- src/tools/index.ts:98-102 (schema)Zod input schema defining parameters for the import_folder tool: folderPath (required), binName (optional), recursive (optional).inputSchema: z.object({ folderPath: z.string().describe('The absolute path to the folder containing media files'), binName: z.string().optional().describe('The name of the bin to import the media into'), recursive: z.boolean().optional().describe('Whether to import from subfolders recursively') })
- src/tools/index.ts:448-449 (registration)Registration and dispatch of the import_folder tool within the executeTool switch statement, mapping the tool name to its handler.case 'import_folder': return await this.importFolder(args.folderPath, args.binName, args.recursive);
- src/tools/index.ts:96-103 (registration)Tool registration in the getAvailableTools() method, defining name, description, and schema.name: 'import_folder', description: 'Imports all media files from a folder into the current Premiere Pro project.', inputSchema: z.object({ folderPath: z.string().describe('The absolute path to the folder containing media files'), binName: z.string().optional().describe('The name of the bin to import the media into'), recursive: z.boolean().optional().describe('Whether to import from subfolders recursively') }) },