Ich verwende erfolgreich das folgende extend-Skript (mit json2.js), um eine lokale JSON-Datei zu lesen und eine Textebene in meinem Projekt zu ändern. Wie kann ich dieses Skript so ändern, dass es beim Ausführen ständig nach neuen JSON-Dateien sucht, die zum Verzeichnis hinzugefügt werden, und den Rest des Skripts ausführt?Wie kann ich einen Ordner für After Effects festlegen, um nach JSON-/Textdateien zu suchen?
#include "json2.js" // jshint ignore:line
var script_file = File($.fileName); // get the location of the script file
var script_file_path = script_file.path; // get the path
var file_to_read = File(script_file_path + "/unique-job-id.json");
var my_JSON_object = null; // create an empty variable
var content; // this will hold the String content from the file
if(file_to_read !== false){// if it is really there
file_to_read.open('r'); // open it
content = file_to_read.read(); // read it
my_JSON_object = JSON.parse(content);// now evaluate the string from the file
//alert(my_JSON_object.arr[1]); // if it all went fine we have now a JSON Object instead of a string call length
var theComposition = app.project.item(1);
var theTextLayer = theComposition.layers[1];
theTextLayer.property("Source Text").setValue(my_JSON_object.arr[2]);
file_to_read.close(); // always close files after reading
}else{
alert("Error reading JSON"); // if something went wrong
}
Ich denke, es ist nicht möglich, ein Skript permanent im Hintergrund laufen zu lassen. Das Skript blockiert den aktuell ausgeführten UI-Thread. Sie könnten einen Blick in die Plugin-Entwicklung für After Effects werfen. [adobe.com/devnet/aftereffects](http://www.adobe.com/devnet/aftereffects.html) – fabianmoronzirfas