Forums › Adobe After Effects Expressions › Unable to create a system level text file
-
Unable to create a system level text file
Tomas Bumbulevičius updated 2 years, 5 months ago 2 Members · 2 Posts
-
Avinash Ramanath
August 3, 2020 at 8:42 pmHi,
I want to create a text file via after effects on a mac. I am using the code below but I don’t know what is going wrong as I am unable to create the folder. I have enabled Write and network access inside after effects. Please help.var scriptFolderPath = File($.fileName).path; //alert(scriptFolderPath)
var s = File(scriptFolderPath + "/testfile.txt"); -
Tomas Bumbulevičius
August 4, 2020 at 11:16 amHey Avinash, check the code below, stripped it down from my scripts, but should be fine / close to it.
var logFileName = "build-log"; //Log file name
var scriptFolder = new File($.fileName).path; //Script path folder
var logFile = initiateLogFile(scriptFolder, logFileName);logFile.open("a"); //Open file for appending
logFile.write("_____"); //Add your logging message
logFile.close(); //Always don't forget to close after writing the filefunction initiateLogFile(rootLocation, rootTitle) {
var logFile = File(rootLocation.toString() + "/" + rootTitle + ".txt");
logFile.encoding = "UTF-8";
if (!logFile.exists) {
logFile.open("w");
logFile.close();
}
return logFile;
}Find out more:
Motion Graphics Design & After Effects Tutorials
On YT
On VH
Log in to reply.