• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

SCRIPTING for Premiere Pro

Engaged ,
Oct 04, 2016 Oct 04, 2016

Copy link to clipboard

Copied

So there are plenty of tutorials for scripting in Adobe After Effects and lots of documentation.  But, as I understand, this isn't the situation for Adobe Premiere Pro.  I presume scripting is possible considering:

69447b12e961459f9058620ab6164927.png

But I have absolutely no idea how to get started.

The end goal is to create a script that will look throughout all of my imported project files (for the current open Premiere Pro project) and then use the "replace footage" command to swap every file that meets a certain file name criteria with other files in a specified directory that meet the same criteria.  So, for example, if I have:

DSTCNarration(1.1).flac

DSTCNarration(1.2).flac

DSTCBattle(BLURRED).mxf

SlowYellowMotion(BACK).mxf

DSTC(PREV).psd

imported into my project, then, when the script is run, it should prompt the user for a new file directory, which I would then enter manually, and then the script should automatically replace the five files above with five different files in the new specified directory by searching for files names based on certain file name criteria:

ARBITRARYNarration(1.1).flac

ARBITRARYNarration(1.2).flac

ARBITRARY(BLURRED).mxf

ARBITRARY(BACK).mxf

ARBITRARY(PREV).psd

And then if there are two files that meet the criteria or there isn't a file that meets the criteria, it could just return an error while still carrying out whatever other replacements that it can.

A script like this could save me tons of time.  Rather than having to use "replace footage" for every clip individually and constantly navigating back to the same folder, it could all be done in one go for all of the files (as long as my new files are named appropriately).

So, is this even possible?  Is scripting in Premiere Pro this advanced even possible?  If so, how should I go about figuring out how to get a script to do this?  Would creating a plugin be more suitable for something like this?  Can any of you write a script that would do this?

TOPICS
SDK

Views

22.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Oct 05, 2016 Oct 05, 2016

Hi, scripting in Premiere is possible.

Therefore you would have to use Adobe´s Panel APIs. You basically create an HTML5 file with some buttons that trigger some scripting.

Once you have the HTML Panel with some buttons running, you start to communicate with Premiere using ExtendScript (which is the actual API to Premiere). ExtendScript is very similar to JavaScript. I´ve put a sample Panel together for you which should get you pretty far:

GitHub - ThomasSzabo/Minimalistic-Adobe-Premiere-Pro-Panel: This Premiere extension is a minimum in order to run a Panel…

...

Votes

Translate

Translate
LEGEND ,
Oct 04, 2016 Oct 04, 2016

Copy link to clipboard

Copied

I presume scripting is possible

I don't believe it is in PP, only in AE.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 04, 2016 Oct 04, 2016

Copy link to clipboard

Copied

I've found some forums saying that scripting is possible in Premiere but there's just minimal documentation.  Even if this is possible with a script, how difficult would it be to develop a plugin that does this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 04, 2016 Oct 04, 2016

Copy link to clipboard

Copied

I've never heard of  someone actually pulling off scripting in PrPro ... not that I'm a great expert, but having been around these forums quite a bit over the last few years, and getting some fascinating time at NAB listening to heavy AE fellas comparing scripts and lamenting they couldn't do this within PrPro, I don't know that it is feasible.

As to developing a plug-in, well ... for that you'd need a decent coder who can decipher the PrPro programming, the released SDK's I suppose, anything like that, and take a guesstimate.

Good luck  ... not sure anyone here has the tool-set and the interest, however.

Neil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 05, 2016 Oct 05, 2016

Copy link to clipboard

Copied

Hi, scripting in Premiere is possible.

Therefore you would have to use Adobe´s Panel APIs. You basically create an HTML5 file with some buttons that trigger some scripting.

Once you have the HTML Panel with some buttons running, you start to communicate with Premiere using ExtendScript (which is the actual API to Premiere). ExtendScript is very similar to JavaScript. I´ve put a sample Panel together for you which should get you pretty far:

GitHub - ThomasSzabo/Minimalistic-Adobe-Premiere-Pro-Panel: This Premiere extension is a minimum in ...

You can read about this here: CEP 6 HTML Extension Cookbook for CC 2015 · Adobe-CEP/CEP-Resources Wiki · GitHub

Also please check the PPro Sample extension here: Samples/PProPanel at master · Adobe-CEP/Samples · GitHub

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 05, 2016 Oct 05, 2016

Copy link to clipboard

Copied

moving thread to Premiere SDK

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 05, 2016 Oct 05, 2016

Copy link to clipboard

Copied

Thank you.  I was able to get the panel into Premiere, so now it's just a matter of making it do what I want to.  I haven't had too much time to play around with it yet.  In the meantime, do you know of any documentation whatsoever of Premiere Pro, perhaps similar to (not necessarily official) what we have for After Effects?

http://blogs.adobe.com/wp-content/blogs.dir/48/files/2012/06/After-Effects-CS6-Scripting-Guide.pdf?f...

Even if somebody else put it together, something like that for Premiere would be extremely helpful for me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 05, 2016 Oct 05, 2016

Copy link to clipboard

Copied

There is no documentation but the CEP Cookbook and the Samples.

I recommend to read through the Cookbook to get a basic understanding (even if  some of this stuff doesn´t make sense yet). Then focus on what you want to achieve and search the PPro Sample Code for examples. The Sample Panel covers 70-80% of the APIs in practical way.

In your case it´s a combination of using

  • getMediaPath() - returns a media file´s path
  • canChangeMediaPath()
  • changeMediaPath()

In the PProPanel Sample, there is a function that you should take a closer look: "replaceMedia"

I hope this helps.

Thomas

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 07, 2016 Oct 07, 2016

Copy link to clipboard

Copied

Would it be possible to create a script that only does one function so that it could be assigned to a keyboard shortcut?  I'm not sure that I want to go through all the trouble of creating a panel for a script designed to only do one thing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 08, 2016 Oct 08, 2016

Copy link to clipboard

Copied

I have successfully created the script I was looking for thanks to your help.  If interested, here's the final version:

var BCV_File_Suffix = ["(PREV).psd", "(BACK).mxf", "(BATT).mxf", "1.1(NARR)_Fixed.flac", "2.1(NARR)_Fixed.flac"];

for (j = 0; j <= 4; j++)

{

   

for (i = 0; i <= app.project.rootItem.children.numItems; i++)

{

     var BCVchild = app.project.rootItem.children;

     if (!BCVchild) continue;

     var mediaPath = BCVchild.getMediaPath();

     if (mediaPath && mediaPath.length > 0 && mediaPath.indexOf(BCV_File_Suffix) > -1)

     {

        var BCVpath = (app.project.path).toString().replace(/\\/g, '\\').replace('\\\\?\\','').replace('(PROJ).prproj',BCV_File_Suffix)

        app.project.rootItem.children.changeMediaPath(BCVpath);

        app.project.rootItem.children.name = app.project.name.replace('(PROJ).prproj',BCV_File_Suffix)

     }

}

}

Thank you so much!  The only downside to what I have here is that it requires the prefix of every file's name to be the same as the prefix of the name of the Premiere Project File, but I guess that's a good thing in terms of keeping me organized.  I don't think a wildcard would work in place of the prefix of every file since that would require the script to search through the directory to use any file containing the specified suffix.  Maybe I'm wrong, but I'm happy with what I have.

Now the question is, it is possible to assign this script to a keyboard shortcut within Premiere Pro?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 11, 2016 Oct 11, 2016

Copy link to clipboard

Copied

Now the question is, it is possible to assign this script to a keyboard shortcut within Premiere Pro?

I don't think you can directly assign an ExtendScript to a keyboard shortcut in Premiere. Bruce Bullis would be able to confirm that.

But, here is another way you may be able to achieve it.

You will need to create a CEP HTML extension. This extension can either provide some UI for your user (in the form of a dockable panel, or a floating window), or it can also have no visible UI. Probably what you want will be an invisible extension. You can refer to these samples:

The famous PProPanel maintained by Bruce Bullis, which demonstrates the many Premiere APIs that you can use:

Samples/PProPanel at master · Adobe-CEP/Samples · GitHub

Sample of an invisible extension with no UI (this one runs a mini HTTP server on Premiere launch):

Samples/CEP_HTML_Invisible_Extension at master · Adobe-CEP/Samples · GitHub

This invisible extension will auto-start when Premiere starts, load up a HTML page and execute the JavaScript in it.

In your invisible extension, call the CEP API function described here:

CEP-Resources/CEP_6.1_HTML_Extension_Cookbook.pdf at master · Adobe-CEP/CEP-Resources · GitHub

Search for "Register an interest in specific key events"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 11, 2016 Oct 11, 2016

Copy link to clipboard

Copied

Jing Tao Tan wrote:

Now the question is, it is possible to assign this script to a keyboard shortcut within Premiere Pro?

I don't think you can directly assign an ExtendScript to a keyboard shortcut in Premiere. Bruce Bullis would be able to confirm that.

I can confirm; no, you cannot.

Thomas Szabo's answers [above] are excellent.

PProPanel sample code is the best documentation; feel free to ask specific questions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 12, 2016 Oct 12, 2016

Copy link to clipboard

Copied

Well it looks like I'll have to teach myself how to build that panel if I want to make the script I wrote easily accessible during my regular editing sessions.  Oh boy!  I appreciate all the help I've received from everybody so far.  I'll let you know how building the panel goes when I get around to it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Hello everybody !

I'm just discovering how hazardous it is to try some scripting with Premiere Pro but maybe some of you can give me a hand on my issue ?

For the needs of documentary series, I'm trying to figure if a Version Up plugin is something which can be scripted.

I mean, imagine that I got a project window full of shots named like this.

E02_100_v001

E02_255_v004

E02_300_v002

Each of those shots are individuals folders (E02_100_V001 is in the E02_100's folder, E02_255_V004 in the E02_255's folder...)

I want to create a script/plugin that allows me to, when I select those, replace them with the next version if there is one.

In the example above, my artists just uploaded me a new version for E02_255 and E02_300, in the same folders. So when I select all of my shots in my project windows and run my Script, my shots are now...

E02_100_v001

E02_255_v005

E02_300_v003

Does it sound possible to you ?

Sorry for my english, I'm trying to make myself as clear as I can...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 22, 2016 Nov 22, 2016

Copy link to clipboard

Copied

Sounds possible. A panel can

  • get the path of any projectItem
  • look around in the file system, for directories with interesting names
  • make new bins with interesting names
  • import updated footage into new bins
  • Replace the usage of projectItem[original] with projectItem[updated], in sequences

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 23, 2016 Nov 23, 2016

Copy link to clipboard

Copied

Hi Bruce !

Thanks for the tips ! I succeeded in installing the ProPanel and I'm using this, the CEP 6 and the api_doc to write what I want to do.

However, I'm a little stuck when it comes to look around in the file system.

For the moment, I'm asking him to take each selected media, isolate their extension (v003 for an example) but how can I say :
"Get in its MediaPath Folder and look if there is the same file name with an updated extension"

Any ideas ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 23, 2016 Nov 23, 2016

Copy link to clipboard

Copied

Yes!

You can do OS path manipulation from within JavaScript; Node.js also has helpful path processing tools.

ExtendScript's File and Folder objects can be useful as well; search for "JavaScript Tools Guide CC.pdf", in ExtendScript Toolkit's /SDK directory.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 23, 2016 Nov 23, 2016

Copy link to clipboard

Copied

I'll have a look ! Thanks ! Keep you posted.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 24, 2016 Nov 24, 2016

Copy link to clipboard

Copied

I've got some news !

I succeed in creating a script that takes all the Items of the Project, looks at the source folder and their version number, and then replace them and their names if an up version is available. Otherwise, it's telling a little alert "No Up Version available for *name of the shot*

The last little thing I want to do is to play this script only for some selected Media. And not all of them. Is there any command to do the trick ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 24, 2016 Nov 24, 2016

Copy link to clipboard

Copied

There is currently no API for determining what the selection is, in the project panel. [It's been requested; I'm adding your vote.]

Workaround = User puts projectItems to be processed into a bin with a magical name; "ProcessWithJack'sScript' or something.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

Hi Bruce !

Actualy, using a code found in the PProPanel, I scripted what I wanted but working on the Clips.

So if one or more clips are selected and the VersionUp button is hit, all those clips will be updated with the next v+1 version.

My very last challenge is to make sort of a loop to tell to Premiere : if v002 doesn't exists, check for v003, v004,v005 without creating an infinite loop. Seems easier than the previous challenges but it's early in the morning so....well...I'm still searching.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 27, 2017 Oct 27, 2017

Copy link to clipboard

Copied

Bruce Bullis​

Replace the usage of projectItem[original] with projectItem[updated], in sequences

do you mean you can replace a clip's projectItem reference, similar to "Replace with clip > from bin"?

if so how can one do that?

I've tried even clip.projectItem =

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 27, 2017 Oct 27, 2017

Copy link to clipboard

Copied

> I've tried even clip.projectItem =

You should try that again, in 12.0.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2017 Oct 28, 2017

Copy link to clipboard

Copied

Amazing

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2019 Jul 11, 2019

Copy link to clipboard

Copied

jacko14594222  ha scritto

Hello everybody !

I'm just discovering how hazardous it is to try some scripting with Premiere Pro but maybe some of you can give me a hand on my issue ?

For the needs of documentary series, I'm trying to figure if a Version Up plugin is something which can be scripted.

I mean, imagine that I got a project window full of shots named like this.

E02_100_v001

E02_255_v004

E02_300_v002

Each of those shots are individuals folders (E02_100_V001 is in the E02_100's folder, E02_255_V004 in the E02_255's folder...)

I want to create a script/plugin that allows me to, when I select those, replace them with the next version if there is one.

In the example above, my artists just uploaded me a new version for E02_255 and E02_300, in the same folders. So when I select all of my shots in my project windows and run my Script, my shots are now...

E02_100_v001

E02_255_v005

E02_300_v003

Does it sound possible to you ?

Sorry for my english, I'm trying to make myself as clear as I can...

I've had the same problem with a similar project my shots name for animation project are:

05_005_v01.mov

05_006_v03.mov

I had to find the new version when my clips were offilne (because that means that someone deleted the old version and add a newone):

Here i've done this scritp, that work in a panel that i've made for me, but if you copy and past in ExtendedToolScript it will work:

!

______________________________________SCRIPT_________________________

//numbers of file in rootItme

var numItem =  app.project.rootItem.children.numItems   

    var token = 0

     //start searching the item or the folder that i need

    for (i=0;i<numItem;i++){

         var folder = app.project.rootItem.children[i].name

               //change folder with the foldere where you want to searching for 

         if(folder=="FOLDER"){

                    //i'm searching for a subfolder because in my case i know that my files are always in a subfolder

                    var subFolder =  app.project.rootItem.children[i];    

                    var numItemsSub = subFolder.children.numItems

                    result = searchInFolder(numItemsSub, subFolder);      //start function n1

                    token = 1

                    break;

          }else{

          }

     }

                        //That's the report

                     switch (token){

                            case 0: alert ( localize ("i've not find your folder")); break;

                            case 1:  {  outPut="Result: \n";

                                                for(n=0;n<result.length;n++){

                                                         outPut= outPut+ result[n] + "\n";

                                                  }                           

                                                alert ( localize ( outPut));

                                                break;

                                            }

                        }

     // function number 1 searching in subfolder  

function searchInFolder(numItemsSub,subFolder2){

     var clipResult = new Array();

    for(j=0;j<numItemsSub;j++){

        newSubFolder= subFolder2.children[j];               

        for(k=0;k<newSubFolder.children.numItems;k++){

            file = newSubFolder.children[k]

          // when in my project i have something offilne it's search  delete this and it will search for every single file

            if(newSubFolder.children[k].isOffline()){   

                                              // call repath function

                clipResult.push(rename(newSubFolder.children[k]));   

            }

        } 

    }

    return clipResult;

}

function rename(clip){

     //check if we can change it

   if(clip.canChangeMediaPath()){  

            path = new String(clip.getMediaPath());

               //split path for windows

            allPath = path.split ("\\");

               //here i take the name of the file

            name = new String(allPath[allPath.length -1]);

               //nameArray =  split the name for example: 05_004_v04.mov  i'll have -> ["05","004","v04.mov"] as Array

            nameArray= name.split("_");

               // newNamei'll get only 05_004

                 newName = name.substring (0, name.indexOf(nameArray[nameArray.length-1]));

           //here i get next version in function number 3 and it will return: v05.mov

            newVersion = nameArray[nameArray.length-1];

            manage = 0

            exist = false

         

               // Start cicle that search for new version if the firstone does not exist

            do{             

                newVersion = version(newVersion);

                newPath = path.substring (0,path.indexOf(name)) + newName + newVersion;

                fileTest = new File(newPath);

                manage=manage+1;

                exist = fileTest.exists

                if(manage>10){

                    break;

                }

               }while( !exist);

         

            if(manage>10){

                return name + " -> There is no new version";

                }

            if(exist){

                    //HERE I CHANGE THE PATH

                 if(clip.changeMediaPath(newPath)){

                    //Change clip name in premiere;

                clip.name = newName + newVersion;

                return newName + newVersion + " -> There is new version";

                }else{

                return name+ " ->The new version does not exist";

                }        

                }else{

                    return clip.getMediaPath() + " - ! -It's not possible change the new path - ! -";

                    }

       }else{

            return ""

        }

}

// function number 3

//here in oldVersion will arrive ("v04.mov") and will return ("v05.mov")

function version(oldVersion){

        oldVersion2 = new String(oldVersion);

          // CHANGE ".mov" with your extension (remember the dot before the extention)

       value =  parseInt(oldVersion2.substring (oldVersion2.indexOf("v")+1,oldVersion2.indexOf(".mov")))+1;

     //add more if if you versions have 3 or more digit

       if(value>=10){

           newvalue = "v"+value+".mov";

           return newvalue

           }else{

               newvalue =  "v0"+value+".mov";

               return newvalue

               }

    }

________________________________________END SCRIPT___________________________________

I'm a biginner in Panel for PremeierePro that is a script where you can get ideas.

I hope that this will help you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines