Copy link to clipboard
Copied
Hi
I want to edit a title object using a script. The problem is I don't know which class represents a title object. What I want to do is change the title and also position it where I choose. Please, help with reference!
Thanks ![]()
You'll need to export the title (from the project, to a .prtl file) first.
https://helpx.adobe.com/premiere-pro/using/creating-editing-titles.html
Copy link to clipboard
Copied
There is no API around changing elements of a title.
However, you may find that the .prtl file itself is .xml, formatted in a pretty human-readable fashion...
Copy link to clipboard
Copied
Hi, thanks for your reply
Can you please clarify where exactly can I find and edit the .prtl file?
Copy link to clipboard
Copied
You'll need to export the title (from the project, to a .prtl file) first.
https://helpx.adobe.com/premiere-pro/using/creating-editing-titles.html
Copy link to clipboard
Copied
In our case we reuse the same project in many instances, just as we import it we change the title. Would that therefore be impossible to be done with Extendscript?
Copy link to clipboard
Copied
It's not impossible, IF...
You change the .prtl files on disk, THEN import them into your template project.
Copy link to clipboard
Copied
Hi, thanks a lot!
Should I use the File class and manually replace the whole xml or I could use some XML DOM reader? Sorry, I'm not too familiar with what API's the ExtendScript has access to.
Copy link to clipboard
Copied
There is no ExtendScritp API provided, for parsing XML. Yes, you could use ExtendScript's File class to manipulate XML.
Take a look inside an actual .prtl file; I think you'll be able to figure out which strings need replacing.
Copy link to clipboard
Copied
Hi, so I've done this:
.......
var file = new File("E:\\sub_test\\" + labels_max + ".prtl");
file.open('r', undefined, undefined);
var content = file.read();
file.close();
var name = prompt("enter 1", '');
var sub = prompt("enter 2", '');
content = content.replace(/<TRString>([a-zA-Zа-яА-Я]*)<\/TRString>/, '<TRString>' + name + '</TRString>');
content = content.replace(/<\/TRString>(.*)<TRString>([a-zA-Zа-яА-Я]*)<\/TRString>/, '</TRString>$1<TRString>' + sub + '</TRString>');
//alert(content);
file = new File("E:\\sub_test\\" + labels_max + ".prtl");
file.open('w');
file.write(content);
file.close();
..........
It works okay but then that Title object is messed. The .prtl file has 40 KB size before this execution, and 20 KB after! The contents inside look the same, except for 2 symbols in the beginning of the original prtl which seem to be just 2 bytes long... What am I missing?
Copy link to clipboard
Copied
I can't help you edit the .xml; I think you may need to serialize the text before you write it.
Copy link to clipboard
Copied
Well I could read and write only that part of the file where I need to edit and that managed to keep the proper size. Anyway, Adobe Premiere carasheswhenever I import the .prtl file. I even tried just manually editting these <TRString> tags with a text editor and importing failed again, Premiere crashes.
Copy link to clipboard
Copied
If that's so, then however you're editing the .prtl is breaking it.
Line endings? Did you serialize your modified output, before saving?
Copy link to clipboard
Copied
Actually I found the problem. After the TRString tag there is a CharacterAttributes tag where the RunCount attribute specifies the string length + 1. Having changed the TRString one should also change this attribute and now Premiere doesn't break. I will now proceed to finish my script. Thanks!
Copy link to clipboard
Copied
Well, back here ... Having exported and editted the .prtl file, how can I import it now? Looking at this thread Is it possible to add a clip to a sequence using ExtendScript? I'm thinking that it is not yet supported ...
Copy link to clipboard
Copied
You can import it into the project using importFiles(), or replace an existing .prtl with changeMediaPath().
Copy link to clipboard
Copied
I can import it, but I cannot change the media path - itemToEdit.canChangeMediaPath() returns false. How can I put it into the sequence?
Copy link to clipboard
Copied
Strange; let's pursue further, off-forum...
Copy link to clipboard
Copied
Turns out, I was wrong: when a .prtl is imported, it creates a new Titler instance...which has no path.
So, you can change what's IN the .prtl, then re-import it, but you can't change the title once it's instantiated.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more