Copy link to clipboard
Copied
I have a script that I want to make me choose where to save the file and its name How do I do that please..
Or to save the script in the same location as the analysis files
#target photoshop;
app.bringToFront();
main();
function main(){
var inputFolder = Folder.selectDialog ("Please select folder to process");
if(inputFolder == null) return;
var fileList = inputFolder.getFiles(/\.(jpg|dng|tif|psd|crw|cr2|psb|exr|nef|dcr|dc2|erf|raf|orf|tga|mrw|mos|srf|pic|pct|pxr|pdd|pef|png|x3f|rw2)$/i);
// var outFile = new File(Folder.desktop +"/"+ decodeURI(inputFolder.name) + ".csv");
outFile.open('w');
outFile.writeln("Filename,Mean Bleu,Mean Marron,Mean Jaune,Mean Noir,Mean Rose,Mean Relief\r");
for(var a in fileList){
// open(fileList);
open(fileList[a])
// var area = activeDocument.histogram;
// var luminosity = activeDocument.histogram;
// CMYK Channel
/*var chnls = activeDocument.channels;
chnls.visible ();
for (var i = 0;i < chnls.length;i++) {
chnls.visible = true;
}*/
/*-------------------------------------------------------------*/
activeDocument.channels["COBALT"].visible = true
var Bleu = activeDocument.channels["COBALT"].histogram;
var mean_Bleu = 0;
var total_Bleu = 0;
for (var n_Bleu = 0; n_Bleu < Bleu.length; n_Bleu++) {
total_Bleu = total_Bleu + Bleu[n_Bleu];
};
for (var m_Bleu = 0; m_Bleu < Bleu.length; m_Bleu++) {
var Value_Bleu = Bleu[m_Bleu];
mean_Bleu = mean_Bleu + (m_Bleu * Value_Bleu / total_Bleu);
};
/*-------------------------------------------------------------*/
activeDocument.channels["MARRON"].visible = true
var Marron = activeDocument.channels["MARRON"].histogram;
var mean_Marron = 0;
var total_Marron = 0;
for (var n_Marron = 0; n_Marron < Marron.length; n_Marron++) {
total_Marron = total_Marron + Marron[n_Marron];
};
for (var m_Marron = 0; m_Marron < Marron.length; m_Marron++) {
var Value_Marron = Marron[m_Marron];
mean_Marron = mean_Marron + (m_Marron * Value_Marron / total_Marron);
};
/*-------------------------------------------------------------*/
activeDocument.channels["JAUNE CITRON"].visible = true
var Jaune = activeDocument.channels["JAUNE CITRON"].histogram;
var mean_Jaune = 0;
var total_Jaune = 0;
for (var n_Jaune = 0; n_Jaune < Jaune.length; n_Jaune++) {
total_Jaune = total_Jaune + Jaune[n_Jaune];
};
for (var m_Jaune = 0; m_Jaune < Jaune.length; m_Jaune++) {
var Value_Jaune = Jaune[m_Jaune];
mean_Jaune = mean_Jaune + (m_Jaune * Value_Jaune / total_Jaune);
};
/*-------------------------------------------------------------*/
activeDocument.channels["NOIR"].visible = true
var Noir = activeDocument.channels["NOIR"].histogram;
var mean_Noir = 0;
var total_Noir = 0;
for (var n_Noir = 0; n_Noir < Noir.length; n_Noir++) {
total_Noir = total_Noir + Noir[n_Noir];
};
for (var m_Noir = 0; m_Noir < Noir.length; m_Noir++) {
var Value_Noir = Noir[m_Noir];
mean_Noir = mean_Noir + (m_Noir * Value_Noir / total_Noir);
};
/*-------------------------------------------------------------*/
activeDocument.channels["ROSE"].visible = true
var Rose = activeDocument.channels["ROSE"].histogram;
var mean_Rose = 0;
var total_Rose = 0;
for (var n_Rose = 0; n_Rose < Rose.length; n_Rose++) {
total_Rose = total_Rose + Rose[n_Rose];
};
for (var m_Rose = 0; m_Rose < Rose.length; m_Rose++) {
var Value_Rose = Rose[m_Rose];
mean_Rose = mean_Rose + (m_Rose * Value_Rose / total_Rose);
};
/*-------------------------------------------------------------*/
activeDocument.channels["RELIEF"].visible = true
var Relief = activeDocument.channels["RELIEF"].histogram;
var mean_Relief = 0;
var total_Relief = 0;
for (var n_Relief = 0; n_Relief < Relief.length; n_Relief++) {
total_Relief = total_Relief + Relief[n_Relief];
};
for (var m_Relief = 0; m_Relief < Relief.length; m_Relief++) {
var Value_Relief = Relief[m_Relief];
mean_Relief = mean_Relief + (m_Relief * Value_Relief / total_Relief);
};
/*-------------------------------------------------------------*/
//(Bleu).toFixed(0));
outFile.writeln(decodeURI(activeDocument.name) + "," + (mean_Bleu) + "," + (mean_Marron) + "," + (mean_Jaune) + "," + (mean_Noir) + "," + (mean_Rose) + "," + (mean_Relief) + "\r");
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
outFile.close();
alert("Process complete\nCSV created...\n" + decodeURI(outFile));
}
replace line
// var outFile = new File(Folder.desktop +"/"+ decodeURI(inputFolder.name) + ".csv");
with
outFile = (new File(Folder.desktop +"/"+ decodeURI(inputFolder.name) + ".csv")).saveDlg("Save file","*.csv");
Copy link to clipboard
Copied
replace line
// var outFile = new File(Folder.desktop +"/"+ decodeURI(inputFolder.name) + ".csv");
with
outFile = (new File(Folder.desktop +"/"+ decodeURI(inputFolder.name) + ".csv")).saveDlg("Save file","*.csv");
Copy link to clipboard
Copied
Thank you very much. I am grateful to you. I wish you all success
The problem has been resolved..
I only have another problem, which is that when opening files from an external disk via script, an error occurs with a message saying corrupt files, noting that the files are quite good ..