Skip to main content
Participant
April 11, 2025
Answered

Copy+Paste or Duplicate a sequence with a script?

  • April 11, 2025
  • 2 replies
  • 378 views

Looking to duplicate a sequence a bunch of times using a script and then label each one for a different language. I saw in a different post that the clone function was available. However, whenever I exectue, I get the exception: "sequence.clone is not a function"

For transparency, here is my script:

// List of languages to use as suffixes
var languages = [
"Chinese (Simplified)",
"Spanish Mexican",
"German",
"Czech",
"Polish",
"Slovak",
"Serbian",
"Portuguese-Brazil",
"Italian",
"Spanish",
"Hindi",
"Kannada",
"Marathi",
"Tamil",
"Arabic",
"Macedonian",
"Korean",
"Romanian",
"Swedish",
"Turkish",
"French",
"Thai",
"Hungarian",
"Japanese",
"Slovenian"
];

// Function to duplicate a sequence and rename each duplication with language suffixes
function duplicateAndRenameSequenceWithLanguages(sequenceName, languages) {
var project = app.project;
var sequence = findSequenceByName(project.rootItem, sequenceName);

if (sequence) {
for (var i = 0; i < languages.length; i++) {
var newSequenceName = sequenceName + " - " + languages[i];
var newSequence = sequence.clone();
if (newSequence) {
newSequence.name = newSequenceName;
$.writeln("Created sequence: " + newSequenceName);
} else {
$.writeln("Failed to create sequence: " + newSequenceName);
}
}
} else {
$.writeln("Sequence not found: " + sequenceName);
}
}

// Function to find a sequence by name in the project
function findSequenceByName(item, name) {
$.writeln("Checking item: " + item.name + ", Type: " + item.type);
if (item && item.name === name && item.type === 1) { // Type 1 corresponds to both clips and sequences
if (item.getMarkers) { // Sequences have markers
$.writeln("Found sequence: " + item.name + ", Type: " + item.type);
return item;
}
} else if (item && item.children) {
for (var i = 0; i < item.children.numItems; i++) {
var found = findSequenceByName(item.children[i], name);
if (found) {
return found;
}
}
}
return null;
}

// Debugging: List all items in the project
function listAllItems(item, depth) {
if (item) {
var indent = new Array(depth + 1).join(" ");
$.writeln(indent + "Item: " + item.name + ", Type: " + item.type);
if (item.children) {
for (var i = 0; i < item.children.numItems; i++) {
listAllItems(item.children[i], depth + 1);
}
}
}
}

// Main script execution
var sequenceName = "Main V1"; // Replace with the name of the sequence you want to duplicate

$.writeln("Listing all items in the project:");
listAllItems(app.project.rootItem, 0);

duplicateAndRenameSequenceWithLanguages(sequenceName, languages);

 

Correct answer Dan McSweeney

Hi responsible_Radiance3086,

Thanks for writing, your project sounds like a good one. 

Check out the link below - sequence.close() is a function, but it returns a boolean, not a sequence.

https://ppro-scripting.docsforadobe.dev/sequence/sequence/#sequenceclone

Regards,

Dan

 

2 replies

Dan McSweeneyCorrect answer
Adobe Employee
April 13, 2025

Hi responsible_Radiance3086,

Thanks for writing, your project sounds like a good one. 

Check out the link below - sequence.close() is a function, but it returns a boolean, not a sequence.

https://ppro-scripting.docsforadobe.dev/sequence/sequence/#sequenceclone

Regards,

Dan

 

Kevin J. Monahan Jr.
Community Manager
Community Manager
April 12, 2025

Hey there!
Thanks for your post and welcome to the forum. In the future, for developer related questions, tag the post with the "SDK" tag (I just did that for you). That will alert the appropriate Adobe Experts and product team members best suited to answer such a question. I will have to ask for your patience for a solution from the product team as we are still traveling back from the NAB conference. Hopefully, an Adobe Expert will chime in, in the meantime. I hope that is OK. Sorry for the frustration.

 

Thanks,
Kevin

 

Kevin Monahan - Sr. Community and Engagement Strategist – Adobe Pro Video and Audio