photoshop javascript 打开 atn 文件
photoshop javascript open atn file
我有一个非常烦人的问题。
var Scriptfile = new File($.fileName);
var basePath = Scriptfile.path;
var topFolder = new Folder(basePath+"/actions");
var fileandfolderAr = scanSubFolders(topFolder,/\.(atn)$/i);
var fileList = fileandfolderAr[0];
for (var a = 0 ;a < fileList.length; a++) {
var atnFile = new File(fileList[a]);
alert(atnFile.name);
var rex = new RegExp (decodeURI(atnFile.name.replace(/\.[^\.]+$/, '')), "g");
if (!atnFile.exists) {
alert("Your ActionSet does not exist!\nPlease contact your administrator.");
return false;
}
var actionList = getActionSets();
//if ActionSet Exists remove it.
var flag = 0;
for (var d in actionList) {
if (decodeURI(actionList[d]).match(rex)) {
flag = 1;
continue;
}
}
if (!atnFile.exists) {
alert("File does not exist");
return false;
}
if (flag == 0) {
app.load(atnFile);
}
}
如果 atn 文件未放置在名称中包含白色 space 的文件夹或子文件夹中,则这段代码运行良好。
如果我有一个像 "photoshop script" 这样的文件夹名称,它不会加载我的 atn 文件。
有什么想法吗?
非常感谢!
看来没有人知道怎么解决,各位大佬。我找到了解决方案。我所要做的就是解码文件的路径。我刚刚将 var atnFile = new File(fileList[a]);
替换为 var atnFile= new File(decodeURI(fileList[a]));
。我希望这会在某个时候对某人有所帮助。
我有一个非常烦人的问题。
var Scriptfile = new File($.fileName);
var basePath = Scriptfile.path;
var topFolder = new Folder(basePath+"/actions");
var fileandfolderAr = scanSubFolders(topFolder,/\.(atn)$/i);
var fileList = fileandfolderAr[0];
for (var a = 0 ;a < fileList.length; a++) {
var atnFile = new File(fileList[a]);
alert(atnFile.name);
var rex = new RegExp (decodeURI(atnFile.name.replace(/\.[^\.]+$/, '')), "g");
if (!atnFile.exists) {
alert("Your ActionSet does not exist!\nPlease contact your administrator.");
return false;
}
var actionList = getActionSets();
//if ActionSet Exists remove it.
var flag = 0;
for (var d in actionList) {
if (decodeURI(actionList[d]).match(rex)) {
flag = 1;
continue;
}
}
if (!atnFile.exists) {
alert("File does not exist");
return false;
}
if (flag == 0) {
app.load(atnFile);
}
}
如果 atn 文件未放置在名称中包含白色 space 的文件夹或子文件夹中,则这段代码运行良好。
如果我有一个像 "photoshop script" 这样的文件夹名称,它不会加载我的 atn 文件。
有什么想法吗?
非常感谢!
看来没有人知道怎么解决,各位大佬。我找到了解决方案。我所要做的就是解码文件的路径。我刚刚将 var atnFile = new File(fileList[a]);
替换为 var atnFile= new File(decodeURI(fileList[a]));
。我希望这会在某个时候对某人有所帮助。