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

Bulk packaging

Enthusiast ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

ANy way to package a plethora of PSD files in one shot? I have for instance 20 PSD files that I want to package, each into their own of course... any scripts out there?

TOPICS
Actions and scripting , Windows

Views

1.1K

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

Community Expert , Dec 21, 2023 Dec 21, 2023

Here is an improved 1.1 version of the script:

 

/*
Bulk Package.jsx
v1.1 21st December 2023, Stephen Marsh - Special thanks to c.pfaffenbichler for offering help in extending the original script
https://community.adobe.com/t5/photoshop-ecosystem-discussions/bulk-packaging/td-p/14308824
*/

#target photoshop

if (app.documents.length === 0) {

    var selectFile = File.openDialog("Please select the file/s to package:", Multiselect = true);

    var counter = 0;

    for (var i = 0; i < selectFil
...

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

@Todd_Morgan what do you mean by "package"?

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
Enthusiast ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

I assume you don't use Photoshop for production work...

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 ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

I do everyday. Packaging is normally associated with InDesign or Illustrator to package fonts, links, etc.

I was asking for clarification if this is what you intended or something else.

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
Enthusiast ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

OK so then you understand what packaging is... Photoshop also does packaging.

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
People's Champ ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

rbin_2-1703026693580.png

 

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 ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

quote

Photoshop also does packaging.

By @Todd_Morgan

 

Packaging in Photoshop is slightly different from InDesign and Illustrator. There has to be at least one Smart Object and the file must be saved. 

https://helpx.adobe.com/photoshop/using/create-smart-objects.html

janee_0-1703108311938.png

I don't think it includes fonts.

 

Jane

 

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 ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

If you’re using the current version of Photoshop for Windows or macOS, is there something about the existing File > Package command in Photoshop that isn’t doing the job for you?

 

When I try it, it creates a folder containing the Photoshop document, and also a Links subfolder containing every Linked Smart Object I placed into the Photoshop document.

 

If the goal is to batch package many Photoshop documents into a folder for each of them, a simple batch action might do it.

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
Enthusiast ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

Hmmmm... tried the batch action, didn't work.

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 ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

What is giving you problems in creating such a Script? 

If some Photoshop functionality is not available via DOM one can usually record the corresponding AM-code with ScriptingListener.plugin (if the feature is scriptable at all). 

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 ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

Would all 20 files for packaging be open in Photoshop?

 

Would they all be sitting at the root/top-level of a target folder?

 

Would they be stored in folders, nested inside other folders of a given root/top-level target folder?

 

Would you prefer to manually select the multiple PSD files?

 

The devil is always in the details...

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
Enthusiast ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

That darn devil... yes manually select them all within a project folder.

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 ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

@Todd_Morgan 

 

The following script will batch package selected documents.

 

NOTE: The script will be interrupted if an open file can't be packaged (i.e. the menu item is greyed out). Does not gracefully handle unsaved documents.

 

/*
Bulk Package.jsx
v1.0 20th December 2023, Stephen Marsh
NOTE: The script will be interrupted if an open file can't be packaged (i.e. the menu item is grayed out). Does not gracefully handle unsaved documents.
https://community.adobe.com/t5/photoshop-ecosystem-discussions/bulk-packaging/td-p/14308824
*/

var selectFile = File.openDialog("Please select the file/s to package:", Multiselect = true);
for (var i = 0; i < selectFile.length; i++) {
    var openFiles = app.open(File(selectFile[i]));
}

while (app.documents.length > 0) {
    savePackage();
    activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}

app.beep();

function savePackage() {
    //var theFolder = Folder.selectDialog('Select the package destination for the document "' + activeDocument.name + '":');
    var theFolder = activeDocument.path.fsName;
    var idpackageFile = stringIDToTypeID("packageFile");
    var desc982 = new ActionDescriptor();
    var idto = stringIDToTypeID("to");
    desc982.putPath(idto, new File(theFolder));
    executeAction(idpackageFile, desc982, DialogModes.NO);
}

 

 https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

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
Enthusiast ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

WOW!!!! thanks Stephen... will give it a try later today!!!!!!!!!!!!!!!!!

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 ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

Please allow me some notpicking: 

Opening all the files first may, depending on their number and filesizes, put a bit of a drag on things, so I suspect opening, packaging and closing them individually might (however slightly) improve performance. 

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 ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

@c.pfaffenbichler Agreed 100%!

 

I don't know how to manually select files and save the selected files to an array for opening in a loop.

 

 I do know how to loop through a folder, but that would process all files of a given file type, not the ones selected by the user.

 

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
LEGEND ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

var a = app.openDialog(); //select files

var b = 0; //index

//loop here

app.open(a[b]);

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 ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

@Lumigraphics 

 

Thanks for posting, however, I don't know how to successfully incorporate that into the existing code that I previously posted. I did try, however, working code examples are always more useful to me than shorthand/hints.

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 ,
Dec 20, 2023 Dec 20, 2023

Copy link to clipboard

Copied

quote

@c.pfaffenbichler Agreed 100%!

 

I don't know how to manually select files and save the selected files to an array for opening in a loop.

 

 I do know how to loop through a folder, but that would process all files of a given file type, not the ones selected by the user.

 


By @Stephen_A_Marsh

I think you could do it in the one for-clause, though there might be a risk if one of the files is already open and has unsaved changes. 

for (var i = 0; i < selectFile.length; i++) {
var openFiles = app.open(File(selectFile[i]));
savePackage();
openFiles.close(SaveOptions.DONOTSAVECHANGES);
};

 

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 ,
Dec 21, 2023 Dec 21, 2023

Copy link to clipboard

Copied

@c.pfaffenbichler 

 

That is very good, I do know how to do that – but I didn't think of it in this context and for some reason was fixated on looping over all open files rather than looping over individual files! I think that it may have been due to the multiselect as I have not used that much. Thanks for the insight!

 

I usually add an if/else block to terminate the script if there are already docs open, I'll update the code.

 

It would be good to be able to test for an open file that can't be packaged (i.e. the menu item is greyed out).

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 ,
Dec 21, 2023 Dec 21, 2023

Copy link to clipboard

Copied

The lazy solution would be a try-clause, I guess, and one could use the catch-clause to copy the file to the target folder if it cannot be packaged. 

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 ,
Dec 21, 2023 Dec 21, 2023

Copy link to clipboard

Copied

@c.pfaffenbichler Esoteric or lazy, it's all good if it works!

 

I'll look into the try/catch block, I was trying to figure out how to do this via if/else.

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 ,
Dec 21, 2023 Dec 21, 2023

Copy link to clipboard

Copied

I think for an if-clause you would need to check whether the file contains at least one (Linked) Smart Object; that seems do-able. 

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 ,
Dec 21, 2023 Dec 21, 2023

Copy link to clipboard

Copied

Yes, I was hoping to avoid looping over the layers and nested layer sets for this and was trying to find something more generic to see if a menu item was greyed out.

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 ,
Dec 21, 2023 Dec 21, 2023

Copy link to clipboard

Copied

Here is an improved 1.1 version of the script:

 

/*
Bulk Package.jsx
v1.1 21st December 2023, Stephen Marsh - Special thanks to c.pfaffenbichler for offering help in extending the original script
https://community.adobe.com/t5/photoshop-ecosystem-discussions/bulk-packaging/td-p/14308824
*/

#target photoshop

if (app.documents.length === 0) {

    var selectFile = File.openDialog("Please select the file/s to package:", Multiselect = true);

    var counter = 0;

    for (var i = 0; i < selectFile.length; i++) {
        var openFiles = app.open(File(selectFile[i]));
        try {
            savePackage();
            openFiles.close(SaveOptions.DONOTSAVECHANGES);
            counter++;
        } catch (e) {
            openFiles.close(SaveOptions.DONOTSAVECHANGES);
        }
    }

    alert("Script completed!" + "\r" + "Files selected: " + selectFile.length + "\r" + "Files processed: " + counter);

} else {
    alert('Please close all open documents before running this script!');
}

function savePackage() {
    var theFolder = activeDocument.path.fsName;
    var idpackageFile = stringIDToTypeID("packageFile");
    var desc982 = new ActionDescriptor();
    var idto = stringIDToTypeID("to");
    desc982.putPath(idto, new File(theFolder));
    executeAction(idpackageFile, desc982, DialogModes.NO);
}

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