Hello everyone again! I am trying to complete this "beta version" of a script for batch processing that meets my needs, the script will work to check all folders and subfolders and in some cases will only process .PSD files from different locations, with the file path being were registered in the dialog box, this works very well, my frustration is that I was not able to configure the script so that I can process the same images again by just clicking on the "Process button". It presents an error and I was not able to correct it. All help is valid. var cont = 0;
dlg = new Window("dialog"); dlg.text = "Dialog";
dlg.preferredSize.width = 300; dlg.orientation = "column";
dlg.alignChildren = ["center","top"]; dlg.spacing = 10; dlg.margins = 16;
st1 = dlg.add("statictext", undefined, undefined, {name: "st1" ,truncate:'middle'} ); st1.text = "diretorio";
st1.preferredSize.width = 200; st1.justify = "center";
var desc = null;
try { desc = app.getCustomOptions("8da280d0-518c-11ea-aaef-0800200c9a66")} catch (e) {};
if (desc) try { st1.text = desc.getString(0)} catch (e) {};
b1 = dlg.add("button", undefined, undefined, {name: "b1"}); b1.text = "SelectFolder";
ck1 = dlg.add("checkbox", undefined, undefined, {name: "ck1"}); ck1.text = "inc.Subfolders";
ck1.value=true;
ck2 = dlg.add("checkbox", undefined, undefined, {name: "ck2"}); ck2.text = "Somente PSD ";
b1.onClick=function(){
try{
topFolder = Folder.selectDialog();
if(ck2.value){ fileandfolderAr = scanSubFolders(topFolder, /\.(psd|)$/i);}
else{ fileandfolderAr = scanSubFolders(topFolder, /\.(jpg|jpeg|tif|psd|bmp|gif|png|)$/i);}
fileList = fileandfolderAr[0];
if( topFolder !=null){ st1.text = decodeURI(topFolder.fsName)}
dlg.text = "Dialog " + fileList.length + " Files";
}
catch(e){};
var desc = new ActionDescriptor();
desc.putString(0, st1.text);
app.putCustomOptions("8da280d0-518c-11ea-aaef-0800200c9a66", desc, true);
}
b2 = dlg.add("button", undefined, undefined, {name: "b2"}); b2.text = "Processar";
b2.onClick=function(){
dlg.close();
for( a = 0 ; a < fileList.length; a++) {
docRef = open(fileList[a]);
////// FUNÇÕES SCRIPTS AQUI!
cont = Number(cont)+1 ;
alert ( "Processing..."+ (cont) + " / " + fileList.length);
}
}
dlg.show();
function scanSubFolders(tFolder, mask) { // folder object, RegExp or string
try{
var sFolders = [];
var allFiles = [];
sFolders[0] = tFolder;
for (var j = 0; j < sFolders.length; j++) { // loop through folders
var procFiles = sFolders[j].getFiles();
for (var i = 0; i < procFiles.length; i++) { // loop through this folder contents
if (procFiles[i] instanceof File ) {
if(mask == undefined) {
allFiles.push(procFiles[i]); // if no search mask collect all files
}
if (procFiles[i].fullName.search(mask) != -1) {
allFiles.push(procFiles[i]); // otherwise only those that match mask
}
}
else if (procFiles[i] instanceof Folder) {
if(ck1.value){ sFolders.push(procFiles[i]);} //OPÇÃO PARA IMPORTAR SUPBASTAS
scanSubFolders(procFiles[i], mask); // search the subfolder
}
}
}
return [allFiles,sFolders];
}
catch(e){};
}
... View more