I recently made a sort of fancy photo slideshow for someone, and I like using Ken Burns (Davinci calls them Dynamic Zooms, but credit where credit is due) to make everything feel more dynamic. But I also like the direction to be alternating between zoom in and zoom out. So instead of selecting every other clip manually, I wrote a small script to change the color of every other clip to green. Then went to "Timeline > Select Clips > By Clip Color > Green" and swapped the dynamic zoom on them. Very quick, very easy, and I'm sharing that script with you!
#!/usr/bin/env python
# SelectEveryOtherClip.py — tags every second clip with a clip color so you can select them.
# Works on current timeline. Defaults: all VIDEO tracks, start with the 1st clip, color "Blue".
# Notes:
# • Prints detailed progress to Workspace ▸ Console.
# • Handles empty tracks safely and reports counts per track.
# • Catches and reports any SetClipColor errors so failures aren’t silent.
import sys
import os
import traceback
# We'll resolve the proper module name at runtime (DaVinciResolveScript or bmd)
# ---- USER OPTIONS ----
TRACK_TYPE = "video" # "video" or "audio"
TRACKS = None # None = all tracks of TRACK_TYPE. Or set like [1] or [1,3].
START_WITH_FIRST = True # True = tag 1st, 3rd, 5th... False = tag 2nd, 4th, 6th...
COLOR_TO_SELECT = "Green" # Use a common built‑in color name like "Blue", "Green", "Red".
DRY_RUN = False # True = print what would happen, don't change colors.
# -----------------------
def _get_bmd_module():
"""Return the Resolve scripting module as `bmd`, trying common fallbacks and paths."""
try:
import DaVinciResolveScript as bmd # When running outside Resolve with proper PYTHONPATH
return bmd
except Exception:
pass
try:
import bmd # When running inside Resolve, `bmd` is injected
return bmd
except Exception:
pass
# Try adding common install paths then re-import
candidate_paths = [
"/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules", # macOS
"C:/ProgramData/Blackmagic Design/DaVinci Resolve/Support/Developer/Scripting/Modules", # Windows
"/opt/resolve/Developer/Scripting/Modules", # Linux
]
for p in candidate_paths:
if os.path.isdir(p) and p not in sys.path:
sys.path.append(p)
try:
import DaVinciResolveScript as bmd
return bmd
except Exception:
return None
def set_color_safe(item, color):
"""Set clip color with error handling. Returns True if successful."""
try:
ok = item.SetClipColor(color)
# Some Resolve versions return bool, others None; treat None as success if no exception.
return True if ok is None else bool(ok)
except Exception:
traceback.print_exc()
return False
def main():
try:
bmd = _get_bmd_module()
if not bmd:
print("Could not find the DaVinci Resolve scripting module.\n"
"If running from outside Resolve, set PYTHONPATH to the 'Developer/Scripting/Modules' folder.\n"
"If running from Workspace ▸ Scripts, 'bmd' should be available; try restarting Resolve.")
return
resolve = bmd.scriptapp("Resolve")
if not resolve:
print("Could not acquire Resolve scripting app.")
return
pm = resolve.GetProjectManager()
if not pm:
print("Project Manager not available.")
return
project = pm.GetCurrentProject()
if not project:
print("No project open.")
return
timeline = project.GetCurrentTimeline()
if not timeline:
print("No timeline open.")
return
# Which tracks?
if TRACKS is None:
count = timeline.GetTrackCount(TRACK_TYPE)
tracks = list(range(1, count + 1))
else:
tracks = list(TRACKS)
print(f"Track type: {TRACK_TYPE}")
print(f"Tracks to scan: {tracks}")
total_items = 0
total_tagged = 0
for track_index in tracks:
items = timeline.GetItemListInTrack(TRACK_TYPE, track_index) or []
print(f"Track {track_index}: {len(items)} item(s)")
total_items += len(items)
toggle = START_WITH_FIRST
for idx, item in enumerate(items, start=1):
# Only handle real timeline clips; ignore generators that sometimes lack color
# capability by trying and catching errors.
if toggle:
name = getattr(item, "GetName", lambda: "clip")()
msg = f"Tagging {TRACK_TYPE} T{track_index} #{idx}: {name} → {COLOR_TO_SELECT}"
if DRY_RUN:
print("[DRY RUN] " + msg)
else:
ok = set_color_safe(item, COLOR_TO_SELECT)
print(("[OK] " if ok else "[FAILED] ") + msg)
if ok:
total_tagged += 1
toggle = not toggle
print(f"Done. Considered {total_items} item(s). Tagged {total_tagged} with '{COLOR_TO_SELECT}'.")
print(f"Now use Timeline > Select Clips With Clip Color > {COLOR_TO_SELECT}")
except Exception:
print("Unexpected error:\n" + traceback.format_exc())
if __name__ == "__main__":
main()
