Question

this works fine, opens the pdf in the folder

#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);
}  

but this wont:

var path = 'C:/PhotoshopPortable/'
var processFolder = Folder(path)

it opens some unkown file with (Mozilla ???) licence text.

i dont need the folder dialog, i just want to have the working path in a variable.

Was it helpful?

Solution

the variablename "path" was the problem. Changing it to "workingDir" solved the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top