Skip to main content
Todd_Morgan
Legend
December 19, 2023
Answered

Bulk packaging

  • December 19, 2023
  • 6 replies
  • 2211 views

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?

This topic has been closed for replies.
Correct answer Stephen Marsh

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);
}

6 replies

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
December 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 < 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);
}
Todd_Morgan
Legend
December 22, 2023

THIS IS SO $%^#&$#%&&*$%*& AMAZING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! TYTYTYTYTYTYTYTYTYTY

Stephen Marsh
Community Expert
Community Expert
December 22, 2023

You're welcome!

Stephen Marsh
Community Expert
Community Expert
December 20, 2023

@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

Todd_Morgan
Legend
December 20, 2023

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

Stephen Marsh
Community Expert
Community Expert
December 20, 2023

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

Todd_Morgan
Legend
December 20, 2023

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

c.pfaffenbichler
Community Expert
Community Expert
December 20, 2023

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

Conrad_C
Community Expert
Community Expert
December 20, 2023

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.

Todd_Morgan
Legend
December 20, 2023

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

Kevin Stohlmeyer
Community Expert
Community Expert
December 19, 2023

@Todd_Morgan what do you mean by "package"?

Todd_Morgan
Legend
December 19, 2023

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

Kevin Stohlmeyer
Community Expert
Community Expert
December 19, 2023

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.