Writing to a text file

What type of scripts do you need?

Moderator: byronnash

Post Reply
spewperb
Posts: 4
Joined: November 7th, 2008, 2:18 am

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
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

November 13th, 2008, 11:27 am

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
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

November 14th, 2008, 3:32 am

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