Copy link to clipboard
Copied
Hi,
I have an automation script that reads from a json file to do various things. For months, the utility function which reads the json file has worked perfectly. Suddenly today, it's causing an error that
"file.exists is undefined", same for file.open() and file.close()
What the hell is going on? It's prbably something stupidly simple but I can't solve it.
var jsonfile= File("X:/some/path/this.json");
jsondata = readJson(jsonfile)
function readJson(file){
if (file.exists()){
file.close() //if left open
file.open("r");
while(!file.eof){
line = file.readln() ;
data.push(line) ;
data = data.join("") ;
var parsedData = JSON.parse(data);
return parsedData ;
}
file.close();
}
}
1 Correct answer
to be more specific:
aep = thisArray[1]
alert (aep)
>>"X:/some/path/project.aep"
aep_file = File(aep);
alert(aep_file);
>> "/x/some/other/path/X:/some/path/project.aep"
On the other hand, if i explicity cast the variable
to be more specific:
aep = "X:/some/path/project.aep"
alert (aep)
>>"X:/some/path/project.aep"
aep_file = File(aep);
alert(aep_file);
>> "/x/some/path/project.aep"
And the problems continue...
startframe = thisArray[2] //value ="1001", type string
alert(startframe)
>>1001
startframe = parseInt(thi
Copy link to clipboard
Copied
Nevermind.
I got rid of the file check: file.exists() and it seems to be working again.
Kinda dumb.
Was AE scripting intentionally designed to be difficult and counterintuitive?
Copy link to clipboard
Copied
file.exists is a property, not a method, so I would expect file.exists() to cause problems.
Copy link to clipboard
Copied
Here's a new one...
var aep = 'X:/some/path/project.aep';
alert(aep);
//alerts "X:/some/path/project.aep"
aep_file = File(aep);
alert(aep_file);
//alerts "X:/some/other/path/X:/some/path/project.aep"
app.ope(aep_file)
Error: "...path is not valid"
No sh-t. Why is it adding an additional path when I've explicity told it what the path is?
Copy link to clipboard
Copied
This works perfectly for me:
var aep = '/c/test/project.aep';
var aep_file = File(aep);
app.open(aep_file);
Copy link to clipboard
Copied
to be more specific:
aep = thisArray[1]
alert (aep)
>>"X:/some/path/project.aep"
aep_file = File(aep);
alert(aep_file);
>> "/x/some/other/path/X:/some/path/project.aep"
On the other hand, if i explicity cast the variable
to be more specific:
aep = "X:/some/path/project.aep"
alert (aep)
>>"X:/some/path/project.aep"
aep_file = File(aep);
alert(aep_file);
>> "/x/some/path/project.aep"
And the problems continue...
startframe = thisArray[2] //value ="1001", type string
alert(startframe)
>>1001
startframe = parseInt(thisArray[2]) //value ="1001", type string
alert(startframe)
>>NaN
This is infuriatingly difficult. I need to run a batch process that opens up spcific project files, edits comps and layer properties, and then moves on to the next one. But I'm stuck on parsing data types which seems to be forbidden knowledge.
Copy link to clipboard
Copied
errors were a result of reading from a text file where the array values were pre-loaded with quotation marks.
because the text file was formatted like this:
shotName = "['filename','aep','startframe',...]"
instead of this:
shotName = "[filename,aep,startframe,...]"
this meant that the array value was being read as:
thisArray[1] = ""x/some/path/filename.aep""
be careful how you format text for batch file implementation

