我一直无法找到与我明显的利基案件类似的东西。
我有很多.png文件,所有文件都有矩形或方形透明。我创建了一个查找边界的脚本,并将此信息写入文本文件。
目前的行为是脚本为每个图像创建一个文本文件,并将我需要的信息写入该文件。
目前代码如下:
//Create logfile FOLDER on the desktop
var LogFolder = new Folder(Folder.desktop + "/LogFiles/");
if(!LogFolder.exists) LogFolder.create();
//NOTE TO SELF: Would be optimal if appended to single log file
//Create new LOGFILE in the folder using image name
var Loginfo = new File(Folder.desktop + "/LogFiles/" + activeDocument.name.replace(/\.[^\.]+$/, '') + ".txt");
Loginfo.open("w", "TEXT");
//Write the info to the file
Loginfo.write(activeDocument.name.replace(/\.[^\.]+$/, '') + ", " + selectionWidth + ", " + selectionHeight + ", " + selectionTopLeftXOffset + ", " + selectionTopLeftYOffset);
//Close the log
Loginfo.close();
我已经开始工作,但没有运气使附加到单个文件:
//Create logfile FOLDER on the desktop
var LogFolder = new Folder(Folder.desktop + "/LogFiles/");
if(!LogFolder.exists) LogFolder.create();
//Append to LOGFILE
var Loginfo = new File(Folder.desktop + "/LogFiles/" + "coords.txt");
Loginfo.open("w", "TEXT");
//Write the info to the file
Loginfo.write(activeDocument.name.replace(/\.[^\.]+$/, '') + ", " + selectionWidth + ", " + selectionHeight + ", " + selectionTopLeftXOffset + ", " + selectionTopLeftYOffset + "\r");
//Close the log
Loginfo.close();
附加到单个文件会使创建文件后的工作变得更加容易。任何帮助将不胜感激。
答案 0 :(得分:6)
您目前正在“写入”该文件,而非“追加”。
你应该可以改变
Loginfo.open("w", "TEXT");
到
Loginfo.open("a", "TEXT");