使用Adobe PhotoShop CS4 脚本,JavaScript 提供File
和Folder
类,但我不知道如何从 VBScript 使用这些类。
目前我使用这样的DoJavaScript
功能:
Set appRef = CreateObject("Photoshop.Application")
jsCode = Array(_
"var inFolder = Folder.selectDialog('Select a folder to process');",_
"if(inFolder != null){",_
" var fileList = inFolder.getFiles(/\.(jpg|jpeg|tif|)$/i);",_
" var outFolder = new Folder(decodeURI(inFolder) + '/Edited');",_
" if (outFolder.exists == false) outFolder.create();",_
" for(var i = 0 ;i < fileList.length; i++){",_
" var doc = open(fileList[i]);",_
" doc.flatten();",_
" var docName = fileList[i].name.slice(0,-4);",_
" var saveFile = new File(decodeURI(outFolder) + '/' + docName + '.png');",_
" SavePNG(saveFile);",_
" activeDocument.close(SaveOptions.DONOTSAVECHANGES);",_
" }",_
"}",_
"function SavePNG(saveFile){",_
" pngSaveOptions = new PNGSaveOptions();",_
" pngSaveOptions.embedColorProfile = true;",_
" pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;",_
" pngSaveOptions.matte = MatteType.NONE;",_
" pngSaveOptions.quality = 1;",_
" pngSaveOptions.PNG8 = false;",_
" pngSaveOptions.transparency = true;",_
" activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);",_
"}")
appRef.DoJavaScript(Join(jsCode, vbNewLine))
我的问题是:我可以直接从我的 VB 脚本中使用Folder
和类吗?File
就像是:
Set psFolder = appRef.Folder
inputFolder = psFolder.selectDialog("Select a folder to process")
当我尝试这个时,appRef.Folder
返回这个错误:
对象不支持此属性或方法