Copy link to clipboard
Copied
bonjour existe t il un script qui permet de selection un dossier et ses sous dossier
d ouvrir tout les sources photoshop, mettre à jour les liens qu il y en a, et faire un png au meme emplacement que chacun des fichiers sources?
Hello @laurence roussel12011930,
Give the below script a try...
var topFolder = (Folder.selectDialog("Select the top level folder."))
var fileandfolderArray = scanSubFolders(topFolder,/\.(psd)$/i);
var fileList = fileandfolderArray[0];
for (var i = 0; i < fileList.length; i++) {
var myFile = fileList[i];
app.open(myFile);
while (app.documents.length > 0) {
var doc = app.activeDocument;
var docName = fileList[i].name.replace(/\.[^\.]+$/, '');
var outputFolder = Folder(doc.path);
var ne
...
Copy link to clipboard
Copied
Hello @laurence roussel12011930,
Give the below script a try...
var topFolder = (Folder.selectDialog("Select the top level folder."))
var fileandfolderArray = scanSubFolders(topFolder,/\.(psd)$/i);
var fileList = fileandfolderArray[0];
for (var i = 0; i < fileList.length; i++) {
var myFile = fileList[i];
app.open(myFile);
while (app.documents.length > 0) {
var doc = app.activeDocument;
var docName = fileList[i].name.replace(/\.[^\.]+$/, '');
var outputFolder = Folder(doc.path);
var newFile = new File(decodeURI(outputFolder) + "/" + docName + ".png");
app.runMenuItem(stringIDToTypeID("placedLayerUpdateAllModified"));
exportOptions = new ExportOptionsSaveForWeb();
exportOptions.format = SaveDocumentType.PNG;
exportOptions.PNG8 = false; // false = PNG-24
exportOptions.transparency = true; // true = transparent
exportOptions.interlaced = false; // true = interlacing on
exportOptions.includeProfile = true; // false = don't embedd ICC profile
doc.exportDocument(newFile, ExportType.SAVEFORWEB, exportOptions);
doc.close(SaveOptions.SAVECHANGES);
}
}
alert("Done processing files!")
function scanSubFolders(tFolder, scanMask){
var subFolders = new Array();
var allFiles = new Array();
subFolders[0] = tFolder;
for (var j = 0; j < subFolders.length; j++){
var procFiles = subFolders[j].getFiles();
for (var i = 0; i< procFiles.length; i++){
if (procFiles[i] instanceof File ){
if(scanMask == undefined) allFiles.push(procFiles[i]);
if (procFiles[i].fullName.search(scanMask) != -1) allFiles.push(procFiles[i]);
}else if (procFiles[i] instanceof Folder){
subFolders.push(procFiles[i]);
scanSubFolders(procFiles[i], scanMask);
}
}
}
return [allFiles,subFolders];
};
Regards,
Mike
Copy link to clipboard
Copied
thanks very much, it work perfectly, i have juste a question, how to add the script into favorite action (script) list, for have a quick open?
ans second question , i have attached 2 picture, my psd file are mockup, a pdf file is linked inside
how to update all file linked into the first psd file, because for open the pdf file, i need double click on dynamic object (this mockup is not do by my self, i very newbi in photoshop
thanks
Copy link to clipboard
Copied
For your first question, you can record an Action of the process of you going to the file menu/Scripts/...and select your script. Then if you want, you can assign a Function key to trigger the script, this will allow you to hit the assigned Function key and the script will run.
For your second question, I do not understand what you're assking...sorry.
Regards,
Mike
Copy link to clipboard
Copied
you answer at my second question
i have record an action for update the dynamical object inside my psd
the function key is f2 (name is update pdf)
how to insert this action into your script?
mean open psd, use my action,save, export to png, close
Copy link to clipboard
Copied
hi mike, i have finish to link all my 600 combinations product with each pdf label... no i would like know how to insert my "F2" function key into you script for open the psd file, update the object with link, save as png in same folder than source, and save and close thanks in advance
Copy link to clipboard
Copied
1. Save the script here:/Applications/Adobe Photoshop 2022/Presets/Scripts.
2. Record an Action of the process of you going to the file menu/Scripts/Select and run the Script.
3. Double click on the action to get the "Action Options" window, here you can assign a Function key to trigger the script, this will allow you to just activate Photoshop and hit the assigned Function key and the script will run.
Regards,
Mike
Copy link to clipboard
Copied
thanks that is done, but my question was
how to insert this "script" into your script
and i have not write the script, only register my action, how to save it into /Applications/Adobe Photoshop 2022/Presets/Scripts
Copy link to clipboard
Copied
Copy the code from the script I posted, open TextEdit if you're on a Mac or NotePad if you're on Windows and set the Format to Plan text, paste the code and save the file with the .jsx file extension.
Now follow the instructions from my last post...
Regards,
Mike
Copy link to clipboard
Copied
i think my english is very bad...i have understand what you mean, your script work very fine and export all my psd file to png in same folder
but my png have a link inside with a pdf file, and before export to png, i need to update it, you script is cool because automatic, but if i need to open all before and press f2 short key before.....
it s for that i ask you how to insert the link update into your script?
Copy link to clipboard
Copied
I added this line to my code to trigger your action to update pdf...I hope it works in your French version of Photoshop.
try{app.doAction("update pdf", "Actions par défaut")}catch(e){}
Here's the entire script...
var topFolder = (Folder.selectDialog("Select the top level folder."))
var fileandfolderArray = scanSubFolders(topFolder,/\.(psd)$/i);
var fileList = fileandfolderArray[0];
for (var i = 0; i < fileList.length; i++) {
var myFile = fileList[i];
app.open(myFile);
while (app.documents.length > 0) {
var doc = app.activeDocument;
var docName = fileList[i].name.replace(/\.[^\.]+$/, '');
var outputFolder = Folder(doc.path);
var newFile = new File(decodeURI(outputFolder) + "/" + docName + ".png");
try{app.doAction("update pdf", "Actions par défaut")}catch(e){}
app.runMenuItem(stringIDToTypeID("placedLayerUpdateAllModified"));
exportOptions = new ExportOptionsSaveForWeb();
exportOptions.format = SaveDocumentType.PNG;
exportOptions.PNG8 = false; // false = PNG-24
exportOptions.transparency = true; // true = transparent
exportOptions.interlaced = false; // true = interlacing on
exportOptions.includeProfile = true; // false = don't embedd ICC profile
doc.exportDocument(newFile, ExportType.SAVEFORWEB, exportOptions);
doc.close(SaveOptions.SAVECHANGES);
}
}
alert("Done processing files!")
function scanSubFolders(tFolder, scanMask){
var subFolders = new Array();
var allFiles = new Array();
subFolders[0] = tFolder;
for (var j = 0; j < subFolders.length; j++){
var procFiles = subFolders[j].getFiles();
for (var i = 0; i< procFiles.length; i++){
if (procFiles[i] instanceof File ){
if(scanMask == undefined) allFiles.push(procFiles[i]);
if (procFiles[i].fullName.search(scanMask) != -1) allFiles.push(procFiles[i]);
}else if (procFiles[i] instanceof Folder){
subFolders.push(procFiles[i]);
scanSubFolders(procFiles[i], scanMask);
}
}
}
return [allFiles,subFolders];
};
Regards,
Mike
Copy link to clipboard
Copied
ok if i understand you call the action name, you do no write the "code" for this action, i will try thanks mike
Copy link to clipboard
Copied
work perfectly, big thanks at you, i m so happy
1 problem is resolved
now need to find the exactly same for indesign, and export to pdf interactive
and need to find a script all indesign files into folder and sub folder, open/update link/save/close
Copy link to clipboard
Copied
little question, it s possible to define, if psd file have not pdf link, just save in png
because i have lot of files with pdf link, but some files without, and the script stop and give an error when it don t find pdf
thanks
Copy link to clipboard
Copied
In your action " update pdf" are you running another script? If so, can you post the code for that script also post the error message you're getting.
Regards,
Mike
Copy link to clipboard
Copied
Copy link to clipboard
Copied
FYI, I can't read the French in the error messages you posted, I can only read english. You can try this script to see if it works for you as I have not thoroughly tested it...
var topFolder = (Folder.selectDialog("Select the top level folder."))
var fileandfolderArray = scanSubFolders(topFolder,/\.(psd)$/i);
var fileList = fileandfolderArray[0];
for (var i = 0; i < fileList.length; i++) {
var myFile = fileList[i];
app.displayDialogs = DialogModes.NO;
app.open(myFile);
while (app.documents.length > 0) {
var doc = app.activeDocument;
var docName = fileList[i].name.replace(/\.[^\.]+$/, '');
var outputFolder = Folder(doc.path);
var newFile = new File(decodeURI(outputFolder) + "/" + docName + ".png");
try{app.doAction("update pdf", "Actions par défaut")}catch(e){}
try{app.runMenuItem(stringIDToTypeID("placedLayerUpdateAllModified"))}catch(e){}
exportOptions = new ExportOptionsSaveForWeb();
exportOptions.format = SaveDocumentType.PNG;
exportOptions.PNG8 = false; // false = PNG-24
exportOptions.transparency = true; // true = transparent
exportOptions.interlaced = false; // true = interlacing on
exportOptions.includeProfile = true; // false = don't embedd ICC profile
doc.exportDocument(newFile, ExportType.SAVEFORWEB, exportOptions);
doc.close(SaveOptions.SAVECHANGES);
}
}
app.displayDialogs = DialogModes.ALL;
alert("Done processing files!")
function scanSubFolders(tFolder, scanMask){
var subFolders = new Array();
var allFiles = new Array();
subFolders[0] = tFolder;
for (var j = 0; j < subFolders.length; j++){
var procFiles = subFolders[j].getFiles();
for (var i = 0; i< procFiles.length; i++){
if (procFiles[i] instanceof File ){
if(scanMask == undefined) allFiles.push(procFiles[i]);
if (procFiles[i].fullName.search(scanMask) != -1) allFiles.push(procFiles[i]);
}else if (procFiles[i] instanceof Folder){
subFolders.push(procFiles[i]);
scanSubFolders(procFiles[i], scanMask);
}
}
}
return [allFiles,subFolders];
};
Regards,
Mike
Copy link to clipboard
Copied
@Mike Bro – You need to post scripts more often! :]
Copy link to clipboard
Copied
i m not really familiar with script....but i admire people like you, it look like so easy for you
Copy link to clipboard
Copied
Should @Mike Bro ’s Script meet your needs remember to mark the post as »Correct Answer«.
Copy link to clipboard
Copied
i have find how to copy paste the code, now i will try
Copy link to clipboard
Copied
i have try the nativ script image processor
it s not png but jpeg, it work but... you can t overwrite if jpg file exist, it will create a new jpeg folder
because i need to link all picture, need same path, same name