• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

script pour export en mass png

Explorer ,
Sep 23, 2022 Sep 23, 2022

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?

TOPICS
Actions and scripting , Windows

Views

825

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Sep 23, 2022 Sep 23, 2022

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
...

Votes

Translate

Translate
Adobe
Advisor ,
Sep 23, 2022 Sep 23, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 25, 2022 Sep 25, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 25, 2022 Sep 25, 2022

Copy link to clipboard

Copied

@laurence roussel12011930,

 

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 26, 2022 Sep 26, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2022 Oct 02, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 02, 2022 Oct 02, 2022

Copy link to clipboard

Copied

@laurence roussel12011930,

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.

Screen Shot 2022-10-02 at 7.31.04 PM.png

 

Regards,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 03, 2022 Oct 03, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 03, 2022 Oct 03, 2022

Copy link to clipboard

Copied

@laurence roussel12011930 

 

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...

https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-pour-export-en-mass-png/m-p/13...

 

Regards,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 03, 2022 Oct 03, 2022

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 03, 2022 Oct 03, 2022

Copy link to clipboard

Copied

@laurence roussel12011930,

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 04, 2022 Oct 04, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 04, 2022 Oct 04, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 04, 2022 Oct 04, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 04, 2022 Oct 04, 2022

Copy link to clipboard

Copied

@laurence roussel12011930,

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 04, 2022 Oct 04, 2022

Copy link to clipboard

Copied

only update

 

we have this problem because the psd file attached is inside my folder, and it s only a basic picture, there no layer with pdf linked

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 07, 2022 Oct 07, 2022

Copy link to clipboard

Copied

LATEST

@laurence roussel12011930,

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2022 Oct 03, 2022

Copy link to clipboard

Copied

@Mike Bro â€“ You need to post scripts more often! :]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 04, 2022 Oct 04, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 25, 2022 Sep 25, 2022

Copy link to clipboard

Copied

Should @Mike Bro â€™s Script meet your needs remember to mark the post as »Correct Answer«. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 25, 2022 Sep 25, 2022

Copy link to clipboard

Copied

i have find how to copy paste the code, now i will try

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 25, 2022 Sep 25, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines