Copy link to clipboard
Copied
Hi,
I'm trying to use ExtendScript ot write a file to an LF (not CRLF) file in Windows. I'm finding that even when I write a string with \n characters, they are being replaced by \r\n characters in the final file.
Is there some magic I'm missing
var writeToFile = function (str, filePath) {
var outFile = new File(filePath);
if (outFile) {
outFile.encoding = "UTF-8";
outFile.open("w", "TEXT", "????");
outFile.write(str);
outFile.close();
}
}
for(var i=0;i<allMarkers.length;i++){
var marker = allMarkers[i];
var line = "AUTHOR\t" + marker.tc + "\tV1\tred\t\t1";
str += line;
if (i < allMarkers.length - 1){
str += "\n"; //Aleays seems to be replaced by \r\n when writing the file
}
}
var outputFilePath = "PATHTO\\" + sequenceName + ".txt";
writeToFile(str, outputFilePath);
What if you specified line feed manually?
outFile.lineFeed = "Unix"; // "Windows", "Macintosh", "Unix"
More info here: http://estk.aenhancers.com/file-system-access/file-object.html?#file-object-properties
Copy link to clipboard
Copied
What if you specified line feed manually?
outFile.lineFeed = "Unix"; // "Windows", "Macintosh", "Unix"
More info here: http://estk.aenhancers.com/file-system-access/file-object.html?#file-object-properties
Copy link to clipboard
Copied
Excellent Tomas. That's works perfectly.
Copy link to clipboard
Copied
Thanks for your input Tomas ...
Find more inspiration, events, and resources on the new Adobe Community
Explore Now