# get all sequencer strips in python

Hello all blenderheads ! i'm trying to make a little script to collect then relink all sequencer strip in a blend file, i'm currently getting something, but only in the active scene, i can't get it work in all scenes in the blend. Here what i've got so far : (sorry it the code isn't so good, im a newbie in python :))

import bpy
import os
import shutil

### make all path absolute ###
bpy.ops.file.make_paths_absolute()

### get the blendfile path ###
blendossier=bpy.path.abspath("//")
blendnom=bpy.path.abspath(bpy.path.basename(bpy.context.blend_data.filepath))

### set the new folder accordingly to blendfile path ###
ressourcesfolder=blendossier + "/" + blendnom + "___ressources"

### create the folder ###
os.makedirs(ressourcesfolder, exist_ok=True)

### get context scene name ###
scname = bpy.context.scene.name

### get all strips in the scene ###
strip = bpy.data.scenes[scname].sequence_editor.sequences_all

### copy strips ###

for obj in strip:
### set a specific folder ###
folder=ressourcesfolder + "/" + "Video Sequencer"

### check if file isn't already in it ###
if bpy.path.abspath(obj.filepath) != folder + "/" + bpy.path.basename(obj.filepath):

### create the folder ###
os.makedirs(folder, exist_ok=True)
### copy the file ###
shutil.copy2(bpy.path.abspath(obj.filepath), folder + "/" + bpy.path.basename(obj.filepath))
### get the new path ###
newpath=folder + "/" + bpy.path.basename(obj.filepath)
### relink the strip to new path ###
obj.filepath=newpath

### make all path relative ###
bpy.ops.file.make_paths_relative()


does anyone have an idea ? i'm stuck with that... thank you !

• You are getting scene name from the context scene. For all in blend file use for scene in bpy.data.scenes: strip = scene.sequence_editor... etc. – batFINGER Jan 27 '17 at 13:29
• Also, might want to test if a sequence editor exist in the scene. – cmomoney Jan 27 '17 at 13:49
• and @cmomoney, if there's no video sequence in the scene, there's no error message, i think thanks to the "for obj in strip:", if there's no obj, it's not a problem ? – tonton Jan 27 '17 at 13:55
• @cmomoney my bad, you were absolutely right ! just added [if scene.sequence_editor is not None:] to the script to get it works even if there wasn't one ! thanks for the remark ! – tonton Jan 27 '17 at 14:13
• @tonton You should post the answer below ;-) – Samoth Jan 30 '17 at 15:52

Hey thanks to batfinger and cmomoney, here's the answer :

### Strips ###
for scene in bpy.data.scenes:

if scene.sequence_editor is not None:

strip = scene.sequence_editor.sequences_all

if strip is not None:


works perfectly to get all the strip in the sequencer editor in any scene of your blend file ! hope it'll help for people in same situation !