-
Notifications
You must be signed in to change notification settings - Fork 4
/
aetextout.jsx
42 lines (38 loc) · 1.55 KB
/
aetextout.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
//There is no undo group since this only effects files external to After Effects.
clearOutput();
var TextOut = new Object;
TextOut.allText = new Array;
TextOut.fileName = (function() {
return $.os.match(/Windows/)
? "/Desktop/aetextio/textout/ textfile.txt"
: ($.os.match(/Mac/) ? "~/Desktop/aetextio/textout/ textfile.txt" : "aetextio/textout/ textfile.txt");
})();
TextOut.start = function(callback) {
for (var i = 1; i <= app.project.numItems; i++) {
if (app.project.item(i) instanceof CompItem) {
for (var j = 1; j <= app.project.item(i).layers.length ; j++) {
if(app.project.item(i).layer(j) instanceof TextLayer){
TextOut.allText.push(app.project.item(i).layer(j).text.sourceText.value.toString().replace(/(,)/g, '\\$1'));
}
}
}
}
callback(TextOut.allText);
};
TextOut.writeFile = function(textArray) {
//Get destination via save dialog, then write it out
//Todo: check if layers are null before calling
var joinText = textArray.join(",");
var initFile = new File(TextOut.fileName);
var textFile = initFile.saveDlg("Save .txt file", "Text: *.txt")
if (textFile != null) {
textFile.open("w");
textFile.write(joinText);
textFile.changePath(textFile);
textFile.close();
}
};
//Execute script
TextOut.start(TextOut.writeFile);
}