Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ExtendScript - Writing LF file on Windows

Explorer ,
Aug 19, 2020 Aug 19, 2020

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);

 

TOPICS
SDK
750
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Aug 20, 2020 Aug 20, 2020

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

Translate
Advocate ,
Aug 20, 2020 Aug 20, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 20, 2020 Aug 20, 2020

Excellent Tomas. That's works perfectly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 14, 2023 Mar 14, 2023
LATEST

Thanks for your input Tomas ...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines