Designing a work script
Hello everyone and best wishes for 2018.
Sorry in advance for my english
I'm starting to try to make photoshop scripts via extendscript. Something that is not simple, the more I progress and the more I encounter difficulties.
Here is my project very precisely:
1. Select the files to be processed
2. Check the files in the first folder
3. Relative to the file name, open, resize, and move to a base image at a specific location
4. Once all the images in the folder have been processed, save a jpeg containing the folder name.
5. Move to the next folder.
I started writing and collecting bits of code, but unfortunately I still can not get them to work properly. In my example, the script opens all the images in the folder, which I do not want. Then, I have not yet managed to write / find the ability to move a layer to my base image and especially to position this layer with XY coordinates.
What I want in the ideal is: check the name, open the image, resize it, copy it on the base image and position it on it. Then do the same with the next picture and so on. Then save a jpeg of this timeline with the name of the source folder and move to the next folder. A bit like a batch treatment.
I do not ask you to make the code (although it will help me a lot), but what interests me the most are the explanations in order to understand and become autonomous for the future.
I am copying the code I currently have and thank you in advance for all the advice and help I can get from you.
#target photoshop
// prefs unites
app.preferences.rulerUnits = Units.PIXELS;
// mode couleur
function ChangeMode () {
doc.changeMode(ChangeMode.RGB);
};
// 4 paramètres : document, largeur hauteur et résolution que tu passe en papramètre en appelent la fonction
function Resize (_doc, _width, _height, _resolution) {
_doc.resizeImage (_width, _height, _resolution);
};
//ouvre toutes images
function open360() {
var filesOpened = 0;
var fileList = inputFolder.getFiles();
for ( var i = 0; i < fileList.length; i++ ) {
open( fileList );
filesOpened++;
}
}
open360();
var doc = app.activeDocument;
var filesOpened = app.activeFiles;
var fileList = inputFolder.getFiles();
//check liste de fichiers et travail dessus
for ( var i = 0; i < fileList.length; i++ ) {
open(fileList);
filesOpened++;
if(fileList.name.indexOf("_Z1") != -1){ //si contient "z1"
Resize(doc, 1630, 1630, 72);
} else if(fileList.name.indexOf("_P") != -1){ //si contient "p"
Resize(doc, 688, 688, 72);
} else if(fileList.name.indexOf("_D1") != -1){ //si contient "d1"
Resize(doc, 688, 688, 72);
} else if(fileList.name.indexOf("_D2") != -1){ //si contient "d2"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_D3") != -1){ //si contient "d3"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_D4") != -1){ //si contient "d4"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_D5") != -1){ //si contient "d5"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_D6") != -1){ //si contient "d6"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_DIV") != -1){ //si contient "div"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_C1") != -1){ //si contient "c1"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_C2") != -1){ //si contient "c2"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_C3") != -1){ //si contient "c3"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_C4") != -1){ //si contient "c4"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_C5") != -1){ //si contient "c5"
Resize(doc, 345, 345, 72);
} else if(fileList.name.indexOf("_C6") != -1){ //si contient "c6"
Resize(doc, 345, 345, 72);
} else { //everything else
//third set of actions
}
}
//ouvrir Mep Vierge
function OpenMepVierge ()
{
var MepVierge = app.open(File("/Applications/Adobe Photoshop CS6/Presets/Scripts/MEP.jpg"));
}
OpenMepVierge ()
