/* Subtitle Exporter v01 Script by Philipp Grolle www.display-artists.de Instructions: Select all the Text Layers you want to export, run the script, and save the file as .srt Attention: The Script has not been debugged or testet. Try it on your own risk! */ // get all the selected Layers var theComp = app.project.activeItem; var alleLayer = theComp.selectedLayers; // count how many layers are selected var anzahlLayer = alleLayer.length; var newLength = alleLayer.length - 1 // Enable the line below if you want to change the order of your text (ascending / descending) /* alleLayer.reverse(); */ // prompt to save file var theFile = File.saveDialog("Save the text file.txt", 'filename.txt', 'text/plain;charset=utf-8'); // if user didn't cancel... if (theFile != null) { theFile.encoding = "utf-8"; // open file for "w"riting, theFile.open("w","TEXT","utf-8"); // Do it for all the selected Layers for (x = 0; x < anzahlLayer; x++) { // get In- and Outpoint of the current Layer and convert to timecode (00:00:00:00) var timecodeIn = timeToCurrentFormat(alleLayer[newLength - x].inPoint, 25); var timecodeOut = timeToCurrentFormat(alleLayer[newLength - x].outPoint, 25); // split the value of the inPoint; converting last 2 characters (frames) to milliseconds, and finally join it again with comma instead of colon var str_in= timecodeIn; var timeCodeAnfang_in=str_in.slice(0,8); var timeCodeEnde_in=str_in.slice(9,11); var millisek_in = timeCodeEnde_in*40; // 1000 milliseconds divided by 25 fps = 40 var zusammen_in = timeCodeAnfang_in +"," + millisek_in; //split the value of the outPoint; converting last 2 characters (frames) to milliseconds, and finally join it again with comma instead of colon var str_out= timecodeOut; var timeCodeAnfang_out=str_out.slice(0,8); var timeCodeEnde_out=str_out.slice(9,11); var millisek_out = timeCodeEnde_out*40; var zusammen_out = timeCodeAnfang_out +"," + millisek_out; //counter for the number above the timecode (in the results) var zaehler = x + 1; // alert("Value is: " + alleLayer[x].name); //writing the results to file theFile.write(zaehler); theFile.write("\r\n"); theFile.write(zusammen_in); theFile.write(" --> "); theFile.write(zusammen_out); theFile.write("\r\n"); theFile.write(alleLayer[newLength - x].property("Source Text").value); theFile.write("\r\n"); } // close the text file theFile.close(); // open text file in default app theFile.execute(); }