How to Import a Folder and Append Clips to a Timeline
Folder scanning, ImportMedia, CreateEmptyTimeline, and AppendToTimeline in a predictable order
Scan a folder for video files, sort them by filename, import them into the Media Pool, create a Timeline when needed, and append the imported clips as a rough assembly.
API
Resolve Scripting API
Language
Python
Resolve
19–20+
Requires
Running Resolve
Syntax
clips = media_pool.ImportMedia(files)
media_pool.AppendToTimeline(clips)Parameters
- • The relevant arguments are shown in the complete working example below. Validate paths, object types, and required project state before calling the API method.
Returns
Always validate the returned object, list, identifier, or boolean before continuing to the next automation step.
import os
import sys
from pathlib import Path
def import_resolve_module():
try:
import DaVinciResolveScript as dvr
return dvr
except ImportError:
search_paths = [
os.environ.get("RESOLVE_SCRIPT_API", ""),
os.environ.get("RESOLVE_MODULES", ""),
r"C:\\ProgramData\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\Modules",
"/opt/resolve/Developer/Scripting/Modules",
"/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules",
str(Path.home() / "Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules"),
]
for path in search_paths:
if path and os.path.isdir(path) and path not in sys.path:
sys.path.append(path)
import DaVinciResolveScript as dvr
return dvr
dvr = import_resolve_module()
media_dir = Path(r"D:\\Resolve\\source")
video_extensions = {".mp4", ".mov", ".mxf", ".avi", ".mkv"}
if not media_dir.is_dir():
raise RuntimeError(f"Folder not found: {media_dir}")
files = sorted(
str(path) for path in media_dir.iterdir()
if path.is_file() and path.suffix.lower() in video_extensions
)
if not files:
raise RuntimeError(f"No video files found in folder: {media_dir}")
resolve = dvr.scriptapp("Resolve")
if not resolve:
raise RuntimeError("Resolve API is unavailable")
project = resolve.GetProjectManager().GetCurrentProject()
if not project:
raise RuntimeError("No project is open")
media_pool = project.GetMediaPool()
clips = media_pool.ImportMedia(files)
if not clips:
raise RuntimeError("Could not import clips")
timeline = project.GetCurrentTimeline()
if not timeline:
timeline = media_pool.CreateEmptyTimeline("API_Timeline")
if not timeline:
raise RuntimeError("Could not create Timeline")
appended = media_pool.AppendToTimeline(clips)
if not appended:
raise RuntimeError("AppendToTimeline did not append any clips")
print("Timeline:", timeline.GetName())
print("Clips appended:", len(clips))Guide
What the example does
The script scans a selected directory, keeps supported video files, sorts the paths by filename, imports them through the Media Pool, and appends the resulting MediaPoolItem objects to the Timeline. It is a compact end-to-end ingest-to-assembly workflow.
Why file order matters
Automated assemblies need deterministic ordering. A simple filename sort is often enough when the files are prepared as 001, 002, 003, and so on. If your production uses another order, replace this step with metadata- or manifest-based sorting.
Creating the Timeline when necessary
If the project has no active Timeline, the script creates an empty one with media_pool.CreateEmptyTimeline("API_Timeline"). AppendToTimeline() then adds the imported items to the sequence.
Scope of this example
The example deliberately focuses on the technical chain: folder → Media Pool → Timeline. Use it as a base for a more advanced assembly script that later adds tracks, trims, markers, graphics, or render automation.
How the example works
Connect to Resolve
Establish a Resolve Scripting API connection and stop early if the application object is unavailable.
Validate the current context
Check the active project, Timeline, Media Pool, source paths, or Render Queue state required by this specific operation.
Run the core API operation
Execute the operation demonstrated in this guide: how to import a folder and append clips to a timeline.
Validate the result
Check the returned value before the workflow continues. Resolve methods often signal an unavailable object or failed operation with None, False, or an empty result.
Resolve API notes
- Path.iterdir() raises an error when the directory does not exist, so validate the path carefully.
- AppendToTimeline expects MediaPoolItem objects, not source-path strings.
- CreateEmptyTimeline returns a Timeline object or None.
- Filename sorting works best when source files are named in the intended sequence order.
Common errors
Resolve API is unavailable
Reason: Resolve is closed or Python cannot import/use DaVinciResolveScript.
Fix: Start Resolve and verify the Developer/Scripting/Modules path from the same Python interpreter used by the script.
The method returns None or False
Reason: A required project, Timeline, clip, preset, path, or application state is missing.
Fix: Validate each input and add explicit result checks after important Resolve API calls.
The script only works on one workstation
Reason: Paths or environment assumptions are hard-coded for a single operating system or machine.
Fix: Move paths into configuration and support the required Windows, Linux, and macOS locations explicitly.
Next step
Continue only after the current operation has returned the expected Resolve object or result.
Related API guides
Media Pool
How to Import Media into the DaVinci Resolve Media Pool with Python
Import files into the active project Media Pool, validate source paths before calling Resolve, and inspect the MediaPoolItem objects returned by ImportMedia().
Timeline
How to Create a Timeline in DaVinci Resolve with Python
Use either an empty Timeline or a Timeline created directly from imported Media Pool clips, depending on how much control your automation needs over the assembly process.
Timeline
How to Iterate Timeline Clips with the DaVinci Resolve Python API
Walk every video and audio track on the active Timeline, inspect TimelineItem objects, and print the name, start frame, and end frame for each clip.

