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.
Code: Select alltry{
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);
}
else if (fileList instanceof Folder) {
processFolder(fileList);
}
}
}
}
catch(error){
alert(String("Error in parent process \n"+error))
}
Subfolders/Folders Issue
-
Mike Hale
Subfolders/Folders Issue
Sorry, I have re-read your post several times and I can't make out what you want to do.
Do you want to limit the script to just one folder? If you don't want to process subfolders just comment out the function call instead of using pop().
Limit the number of files processed in each folder? If so change your loop's test condition. ie instead of i < fileList.length; use i < 3;
If neither of those can you give more detail about what 'which of course isn't ideal.' means?
Do you want to limit the script to just one folder? If you don't want to process subfolders just comment out the function call instead of using pop().
Limit the number of files processed in each folder? If so change your loop's test condition. ie instead of i < fileList.length; use i < 3;
If neither of those can you give more detail about what 'which of course isn't ideal.' means?