-
Read and print specific line from txt file – ExtendScript
I’am trying to read only line 2 from a text file and print. How can I do it? Please help
If text file contains three line
this is line 1
this is line 2
this is line 3I want to print only line 2. (or access any line i want)
my current code:
var dataFile = File("/Users/avinashramanath/Desktop/Content.txt");
dataFile.open("r");
var fields = dataFile.readln();{
var comp = null;
for (var i=1; i<=app.project.numItems; i++)
{
if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name === "RenderComp"))
{
comp = app.project.item(i);
break;
}
}if (comp === null)
{
alert("RenderComp does not exist");}
comp.layer(1).property("Text").property("Source Text").setValue(fields);
}