我的临时文件夹中有几个文件。我可以通过编写以下脚本将它们加载到 Photoshop 中:
var sourceFolder = Folder("C:\\temp");
if (sourceFolder != null)
{
var fileList = sourceFolder.getFiles();
}
这一切都很好,但是我如何忽略也可能存在于其中的目录(例如 C:\temp\waffles)。
我知道我可以检查有效的图像扩展名,然后将它们添加到新的文件列表数组中,然后加载它。我认为搜索选项 TopDirectoryOnly 在这里无效。
最佳答案
由于 getFiles() "Returns an array of File and Folder objects "您将需要迭代返回的每个对象并测试以查看它是什么类型的对象。来自 Adobe Creative Suite 5 Javacript Tools Guide
There are several ways to distinguish between a File and a Folder object. For example:
if (f instanceof File)...<br/> if (typeof f.open == "undefined")... //Folders do not open.
关于javascript - getFiles() 不是文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21631437/