我一直无法找到与我明显利基案件相似的东西.
我有很多.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();
.
附加到单个文件将使创建文件之后的工作变得更加容易.任何帮助将不胜感激.
解决方法:
您当前正在“写入”该文件,而不是“追加”.
> // open()方法
> fileExample.open(“w”); //写
> fileExample.open(“e”); //编辑
> fileExample.open(“a”); //追加
你应该能够改变
Loginfo.open("w", "TEXT");
至
Loginfo.open("a", "TEXT");