Page 1 of 1

Writing to a text file

Posted: November 13th, 2008, 10:11 am
by spewperb
Hi another question (sorry). How can I save a text file from after effects and choose where it is saved?

Thanks in advance

Re: Writing to a text file

Posted: November 13th, 2008, 11:27 am
by Paul Tuersley
I've done a couple of scripts that save text files which you could check out:
http://www.aenhancers.com/viewtopic.php?f=9&t=653
http://www.aenhancers.com/viewtopic.php?f=9&t=31

Let me know if you can't figure it out and I'll do you an example script when I get the time.

Paul

Re: Writing to a text file

Posted: November 14th, 2008, 3:32 am
by Paul Tuersley
Here's an example script that shows how to get AE to write a text file:

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();
	}
}