Select folders before processing

Discussion of Automation, Image Workflow and Raw Image Workflow

Moderators: Tom, Kukurykus

tharealmb

Select folders before processing

Post by tharealmb »

I am in a bit of a pickle here

i created an action with some javascript in it, and converted that to a script.
works like a charm, but it is still missing one feature.

it does something very simple.
it opens a file, and adds other files as layers based on their name.

for example, it opens image1.jpg and imports image1.exr, image1shadow.exr and image1ao.exr

it uses the first filename, and derives the other filenames from it.

my question is, can i make a UI that lets me select the folder with all the images (.jpg)
and after that select the folder with the images to be imported into the same document (image1.exr, image1shadow.exr and image1ao.exr)

im no real programmer, i can read it but not great at writing it.

in short, i want both folders to be stored into a variable, and re-use them later
pfaffenbichler

Select folders before processing

Post by pfaffenbichler »

Maybe this can point you in a right direction:

Code: Select allvar theFolder1 = Folder.selectDialog ("select folder");
var theFolder1Files = retrieveFiles (theFolder1, [], ".jpg");
var theFolder2 = Folder.selectDialog ("select folder");
var theFolder2Files = retrieveFiles (theFolder2, [], ".exr");
alert (theFolder1Files.join("\r")+"\n\n"+theFolder2Files.join("\r"));
////// get from subfolders //////
function retrieveFiles (theFolder, theFiles, theSuffix) {
   if (!theFiles) {var theFiles = []};
   var theContent = theFolder.getFiles();
   for (var n = 0; n < theContent.length; n++) {
      var theObject = theContent[n];
      if (theObject.constructor.name == "Folder") {
         theFiles = retrieveTIFandPSD(theObject, theFiles)
         };
      if (theObject.name.slice(-4) == theSuffix) {
         theFiles = theFiles.concat(theObject)
         }
      };
   return theFiles
   };