# Change sequencer image strip filename through python

i'm trying to access and change the filename of image strips in the sequencer for a little addon i'm developping, but i'm stuck with invalid syntax, i think, and i can't find the correct way to put that... Here's what i've got so far :

import bpy

for scene in bpy.data.scenes:

if scene.sequence_editor is not None:

strip = scene.sequence_editor.sequences_all

if strip is not None:
for obj in strip:
if obj.type == 'IMAGE':

obj.elements.Sequence_Element.filename="ok"


But last line doesn't work... Does anyone have an idea about that ? Or know the correct way ? Thank you very much !

The Sequencer Strip has a name property, which is assigned by the user in Blender. It also has an SequenceElement list which contains all "file" elements of that strip. (Especially with image sequences you have multiple files.) We need to access the SequenceElements filename property. Image strips only have a single SequenceElement which will be indiced with 0.

The correct code is:

import bpy

for scene in bpy.data.scenes:
if scene.sequence_editor is not None:
strip = scene.sequence_editor.sequences_all
if strip is not None:
for obj in strip:
if obj.type == 'IMAGE':
obj.name = "ok"
obj.elements[0].filename = "ok.png"

• perfect thanks you @Leander ! works like a charm ! i was aware of the name attribute, but i want to let it unchanged (because it's up to user to rename its strips) but i didn't know the good way to get to the elements attribute ! perfect ! – tonton Feb 5 '17 at 23:50