Subfolders/Folders Issue
So I am trying to get a handle on getFiles and folder structure.
Currently I have a script that works fine, except it runs repetitively due to how I have my folder call setup. I'm uncertain how to get past it, because it has some functionality I need and frankly I'm new at using .js on folder structures.
So I have a target folder, tFolder, and within this, subfolders to run through the script. Within these folders are .psd files that have a count of 3-5 files.
Currently the script iterates through each file, however many files are in the subfolder, which of course isn't ideal. Could someone help with a modification of the script below? .pop seemed to be the right direction but I couldn't get it to work in this case.
try{
var tFolder = Folder.selectDialog("Select the folder with PSDs to process");
var mainFldr = tFolder.path;
}
catch(error){
alert("User Cancelled Folder Selection")
}
try {
if (tFolder != null) processFolder(tFolder);
function processFolder(folder) {
var fileList = folder.getFiles()
for (var i = 0; i < fileList.length; i++) {
if (fileList instanceof File && fileList.name.match(/\.(psd)$/i)) {
fileOpen(fileList, i);
}
////// This is the area I know I need to rewrite, but I cannot figure out a way to modify this correctly//////////
else if (fileList instanceof Folder) {
processFolder(fileList);
}
}
}
}
catch(error){
alert(String("Error in parent process \n"+error))
}