Writing to a text file
Posted: November 13th, 2008, 10:11 am
Hi another question (sorry). How can I save a text file from after effects and choose where it is saved?
Thanks in advance
Thanks in advance
Code: Select all
{
// prompt to save file
var theFile = filePutDialog("Save the text file.", "untitled.txt", "TEXT txt");
// if user didn't cancel...
if (theFile != null) {
// open file for "w"riting,
theFile.open("w","TEXT","????");
// write a line in the text file
theFile.writeln("Woohoo! I've written to a text file.");
// if a comp is selected, write the name of all the layers
activeItem = app.project.activeItem;
if (activeItem != null && activeItem instanceof CompItem) {
for (x = 1; x <= activeItem.numLayers; ++x) {
theFile.writeln(activeItem.layer(x).name);
}
}
// close the text file
theFile.close();
// open text file in default app
theFile.execute();
}
}