Hi all, I’m new at JavaScript, so please bear with me.
I’m trying to automate some actions for Photoshop to do to a whole bunch of files. Photoshop allows you to write JS to do this, but I can’t seem to get things to work out because I don’t know enough about coding.
So here’s my code, please see notes in the code to see what I’m trying to do:
[CODE]
//set folderpath array
var folderpathGo = new Array();
folderpathGo[0]=”path/12000-xx999″;
folderpathGo[1]=”path/13000-xx999″;
folderpathGo[2]=”path/14000-xx999″;
//set savepath array
var savepathGo = new Array();
savepathGo[0]=”path/_Comps/12000-xx999.psd”;
savepathGo[1]=”path/_Comps/13000-xx999.psd”;
savepathGo[2]=”path/_Comps/14000-xx999.psd”;
function dothisdetlef ( folderpathGo, savepathGo )
{
//start batch process ——–here’s where I want to pass the first
//element of the array into the function——I want “folderpathGo” to be the
//first item in the previously created array
var idBtch = charIDToTypeID( “Btch” );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( “null” );
//——–right here—-in this area, and the savepath one below,
//photoshop needs a string. I would like it to be the string associated
//with folderpathGo[0]
//
desc3.putPath( idnull, new File( folderpathGo ) );
//———
var idUsng = charIDToTypeID( “Usng” );
var ref1 = new ActionReference();
var idActn = charIDToTypeID( “Actn” );
ref1.putName( idActn, “Try1” );
var idASet = charIDToTypeID( “ASet” );
ref1.putName( idASet, “MovieBarcode” );
desc3.putReference( idUsng, ref1 );
executeAction( idBtch, desc3, DialogModes.NO );
//save document
//and here’s where I want to pass the first item in the savepath array
//into the savepathGo spot
var idsave = charIDToTypeID( “save” );
var desc5 = new ActionDescriptor();
var idAs = charIDToTypeID( “As ” );
var desc6 = new ActionDescriptor();
var idmaximizeCompatibility = stringIDToTypeID( “maximizeCompatibility” );
desc6.putBoolean( idmaximizeCompatibility, true );
var idPhtthree = charIDToTypeID( “Pht3” );
desc5.putObject( idAs, idPhtthree, desc6 );
var idIn = charIDToTypeID( “In ” );
//right here——same thing, pass the first savepathGo string into this spot
//
desc5.putPath( idIn, new File( savepathGo ) );
//———-
var idLwCs = charIDToTypeID( “LwCs” );
desc5.putBoolean( idLwCs, true );
executeAction( idsave, desc5, DialogModes.NO );
}
//do it to it.
dothisdetlef ( folderpathGo, savepathGo )
//then I feel like I’m missing something here that will start the whole thing
//over, but move on to the next set for folderpathGo[1] and savepathGo[1]
//and so on and so forth until all items in the arrays have finished processing
//
I have about a hundred folders to stick into the array (each folder has about a thousand files) that would need to be processed, but cut it down to three just to try to figure this out.