Javascript photoshop脚本-路径作为变量
这很好,打开文件夹中的pdfJavascript photoshop脚本-路径作为变量,javascript,photoshop,Javascript,Photoshop,这很好,打开文件夹中的pdf #target photoshop app.bringToFront(); var path = 'C:/PhotoshopPortable/' // A hard coded path to a directory 'mac style' var processFolder = Folder('C:/PhotoshopPortable/') // Use folder object get files function with mask 'a reg ex'
#target photoshop
app.bringToFront();
var path = 'C:/PhotoshopPortable/'
// A hard coded path to a directory 'mac style'
var processFolder = Folder('C:/PhotoshopPortable/')
// Use folder object get files function with mask 'a reg ex'
var fileList = processFolder.getFiles(/\.(pdf)$/i);
// Loop through files
for (var i = 0; i < fileList.length; i++) {
// Only process the returned file objects
// The filter 'should' have missed out any folder objects
if (fileList[i] instanceof File && fileList[i].hidden == false) {
// get a reference to the new document
var docRef = open(fileList[i])
// save and close
saveJPEG(new File('C:/PhotoshopPortable/' + app.activeDocument.name + ".jpg"), 12)
app.activeDocument.close();
}
}
function saveJPEG(saveFile, jpegQuality){
var doc = activeDocument;
if (doc.bitsPerChannel != BitsPerChannelType.EIGHT) doc.bitsPerChannel = BitsPerChannelType.EIGHT;
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}
它打开一些未知的文件,其中包含(Mozilla???)许可证文本
我不需要文件夹对话框,我只想把工作路径放在一个变量中。变量名“路径”就是问题所在。将其更改为“workingDir”解决了问题。尝试将路径格式化为“/c/folder/”
var path = 'C:/PhotoshopPortable/'
var processFolder = Folder(path)