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

Saving multiple files into same folder from actions

Explorer ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

Hi, I'm trying to find a quick way to save as through either actions or shortcut key. The difficulty is that I am saving from the same file but changing layers. If I create an action this then saves over the last file that I saved but I want it to save each one. It's not a process that I can do as a batch, I just want less clicks and no need to type for the save as into the same folder with the same filename (or automatically change file name to help this).

TOPICS
Actions and scripting

Views

3.8K

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 2 Correct answers

Community Expert , Nov 03, 2020 Nov 03, 2020

I don't know why the colour would be "changing", is this colour appearance or the actual colour values? It could indeed be JPEG related, which is not great for large flat areas of solid colour.

 

I changed the script to better suit your purposes, it saves directly into the source folder without asking for a save location and I have removed the PSD option popup. The script will also open up the save folder which can be removed if this is not needed.

 

Look for the JPEG settings towards the end of

...

Votes

Translate

Translate
Community Expert , Nov 16, 2020 Nov 16, 2020

 

Try this revised code:

 

/*
Composite Combinations From Top Level Layer Sets.jsx
Modified 17th November 2020 by Stephen A Marsh
https://community.adobe.com/t5/photoshop/saving-multiple-files-into-same-folder-from-actions/m-p/11564168

Original Script:
https://github.com/mechanicious/photoshopCompositionComposer

Automatically create variable composite JPEG images based on layer content in top level layer sets/groups.
Final montages are saved to the source directory. Not intended for batch proc
...

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

So, is this the result that you are looking for?

 

  • Art-Heron-Frame-Black-Mount-Blue.jpg
  • Art-Maccaw-Frame-Black-Mount-Blue.jpg
  • Art-Parrot-Frame-Black-Mount-Blue.jpg
  • Art-Heron-Frame-Black-Mount-Green.jpg
  • Art-Maccaw-Frame-Black-Mount-Green.jpg
  • Art-Parrot-Frame-Black-Mount-Green.jpg
  • Art-Heron-Frame-Black-Mount-Red.jpg
  • Art-Maccaw-Frame-Black-Mount-Red.jpg
  • Art-Parrot-Frame-Black-Mount-Red.jpg
  • Art-Heron-Frame-Gey-Mount-Green.jpg
  • Art-Heron-Frame-Grey-Mount-Blue.jpg
  • Art-Maccaw-Frame-Grey-Mount-Blue.jpg
  • Art-Parrot-Frame-Grey-Mount-Blue.jpg
  • Art-Maccaw-Frame-Grey-Mount-Green.jpg
  • Art-Parrot-Frame-Grey-Mount-Green.jpg
  • Art-Heron-Frame-Grey-Mount-Red.jpg
  • Art-Maccaw-Frame-Grey-Mount-Red.jpg
  • Art-Parrot-Frame-Grey-Mount-Red.jpg

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 ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

Thanks

 

No, ideally it would be (This is without the white frame option) - 

 

  • Art-Heron-Frame-Black-Mount-Blue.jpg
  • Art-Heron-Frame-Black-Mount-Green.jpg
  • Art-Heron-Frame-Black-Mount-Red.jpg
  • Art-Heron-Frame-Gey-Mount-Green.jpg
  • Art-Heron-Frame-Grey-Mount-Blue.jpg
  • Art-Heron-Frame-Grey-Mount-Red.jpg
  • Art-Maccaw-Frame-Black-Mount-Blue.jpg
  • Art-Maccaw-Frame-Black-Mount-Green.jpg
  • Art-Maccaw-Frame-Black-Mount-Red.jpg
  • Art-Maccaw-Frame-Grey-Mount-Blue.jpg
  • Art-Maccaw-Frame-Grey-Mount-Green.jpg
  • Art-Maccaw-Frame-Grey-Mount-Red.jpg
  • Art-Parrot-Frame-Black-Mount-Blue.jpg
  • Art-Parrot-Frame-Black-Mount-Green.jpg
  • Art-Parrot-Frame-Black-Mount-Red.jpg
  • Art-Parrot-Frame-Grey-Mount-Blue.jpg
  • Art-Parrot-Frame-Grey-Mount-Green.jpg
  • Art-Parrot-Frame-Grey-Mount-Red.jpg

 

It is the layer name within the art folder which is the key element with the frames and mounts above being variations. This is why it would be so useful to have the named like this when I come to then dropping them into the artworks folders / uploaing later.

 

It wouldn't matter if the mount or frame layers came in a different order form the above, purely that all 'Heron' files would end of filing next to each other.

 

Thnak you again for your time on this.

 

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 ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

I didn't sort the files... I was more concerned with the text "patterns"...

 

Apart from sorting order, the actual content/pattern matches, yes?

 

  • Art-Heron-Frame-Black-Mount-Blue.jpg (your latest example)
  • Art-Heron-Frame-Black-Mount-Blue.jpg (my previous example)

 

 

 

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 ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

In the short term, you can use Adobe Bridge's Batch Rename command with a Regular Expression:

 

Find: 

(^.+)(-)(.+-.+)(\.[^\.]+$)

 

Replace:

$3-$1

 

regex.png

 

Then they will sort as you wish:

 

sort.png

 

EDIT (new code below): When I have time I'll add this renaming to the current script code so that you don't need to use Bridge to Batch Rename.

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 ,
Nov 16, 2020 Nov 16, 2020

Copy link to clipboard

Copied

 

Try this revised code:

 

/*
Composite Combinations From Top Level Layer Sets.jsx
Modified 17th November 2020 by Stephen A Marsh
https://community.adobe.com/t5/photoshop/saving-multiple-files-into-same-folder-from-actions/m-p/11564168

Original Script:
https://github.com/mechanicious/photoshopCompositionComposer

Automatically create variable composite JPEG images based on layer content in top level layer sets/groups.
Final montages are saved to the source directory. Not intended for batch processing.

Example:
- A layer set containing one or more "static" images
- A second layer set containing one or more "variable" backgrounds

Top level layer sets with leading double underscore __ characters are ignored
*/

/* Start Open/Saved Document Error Check - Part A: Try */

main();

function main() {
    try {
        app.activeDocument.path;

        /* Finish Open/Saved Document Error Check - Part A: Try */

        /* Main Code Start */

        var userDisplayDialogsPref = app.displayDialogs;
        app.displayDialogs = DialogModes.ALL;
        app.displayDialogs = DialogModes.NO;

        function getCombinations(arr, n) {
            if (n === 1) {
                var ret = [];
                for (var i = 0; i < arr.length; i++) {
                    for (var j = 0; j < arr[i].length; j++) {
                        ret.push([arr[i][j]]);
                    }
                }
                return ret;
            } else {
                var ret = [];
                for (var i = 0; i < arr.length; i++) {
                    var elem = arr.shift();
                    for (var j = 0; j < elem.length; j++) {
                        var childperm = getCombinations(arr.slice(), n - 1);
                        for (var k = 0; k < childperm.length; k++) {
                            ret.push([elem[j]].concat(childperm[k]));
                        }
                    }
                }
                return ret;
            }
        }

        function hideAllArtLayers() {
            var layerSets = app.activeDocument.layerSets;

            for (var i = 0; i < layerSets.length; i++) {
                if (layerSets[i].artLayers.length) {
                    for (var z = 0; z < layerSets[i].artLayers.length; z++) {
                        layerSets[i].artLayers[z].visible = false;
                    }
                } else {
                    for (var z = 0; z < layerSets[i].layerSets.length; z++) {
                        layerSets[i].layerSets[z].visible = false;
                    }
                }
            }
        }

        function getArtLayerCollectionCollection() {
            var layerSets = app.activeDocument.layerSets,
                artLayerCollectionCollection = [];

            for (var i = 0; i < layerSets.length; i++) {
                var artlayerCollection = [];
                if (layerSets[i].artLayers.length) {
                    for (var z = 0; z < layerSets[i].artLayers.length; z++) {
                        if (layerSets[i].name.indexOf('__') !== 0)
                            artlayerCollection.push(layerSets[i].artLayers[z]);
                    }
                } else {
                    for (var z = 0; z < layerSets[i].layerSets.length; z++) {
                        if (layerSets[i].name.indexOf('__') !== 0)
                            artlayerCollection.push(layerSets[i].layerSets[z]);
                    }
                }
                artLayerCollectionCollection.push(artlayerCollection);
            }

            return artLayerCollectionCollection;
        }

        function combine() {
            var artLayerCollectionCollection = getArtLayerCollectionCollection(),
                artLayerCollectionCollectionCombinations = getCombinations(artLayerCollectionCollection, getLayerSetsCount()),
                continueConfirmation;

            // Error message
            if (!artLayerCollectionCollectionCombinations.length) return alert('Script has aborted. No combinations found. Please make sure no empty groups are present.');

            continueConfirmation = confirm(artLayerCollectionCollectionCombinations.length + " combinations found. Would you like to continue?");

            // Cancel message
            if (!continueConfirmation) return alert('Script has been aborted.');

            // Path to open document
            var savePath = app.activeDocument.path;

            for (var i = 0; i < artLayerCollectionCollectionCombinations.length; i++) {
                hideAllArtLayers();
                var artLayerNames = [];
                for (var z = 0; z < artLayerCollectionCollectionCombinations[i].length; z++) {
                    var artLayer = artLayerCollectionCollectionCombinations[i][z];
                    artLayer.visible = true;
                    // Add hyphen separators between layer set names
                    artLayerNames.push('-' + artLayer.parent.name + '-');
                    artLayerNames.push(artLayer.name);
                }

                var tempFilename = normalizeSaveFileName(artLayerNames.join('')).substr(0, 254);
                // Remove leading hyphen from saved filename retaining the other hyphen separators
                var finalFilename = tempFilename.replace(/^-/, '');
                // Shuffle the filename around a bit...
                var finalFinalFilename = finalFilename.replace(/(^.+)(-)(.+-.+)/, '$3-$1');

                saveDocumentAsJPEG(savePath + '/' + finalFinalFilename);
            }

            // Message on successful script run
            alert(artLayerCollectionCollectionCombinations.length + " JPEG files saved to source directory.");
        }

        function getLayerSetsCount() {
            var layerSets = app.activeDocument.layerSets,
                count = 0;

            for (var i = 0; i < layerSets.length; i++) {
                if (layerSets[i].name.indexOf('__') !== 0) count++;
            }

            return count;
        }

        function normalizeSaveFileName(name) {
            return name;
        }

        function saveDocumentAsJPEG(path) {
            app.activeDocument.saveAs(new File(path + '.jpg'), jpegOptions);
        }

        // JPEG Options
        var jpegOptions = new JPEGSaveOptions();
        jpegOptions.quality = 8; // Quality Level
        jpegOptions.embedColorProfile = true; // or false
        jpegOptions.formatOptions = FormatOptions.STANDARDBASELINE;
        jpegOptions.matte = MatteType.NONE;

        combine();

        app.displayDialogs = userDisplayDialogsPref;

        // Open the destination directory/folder
        var saveDir = Folder(app.activeDocument.path);
        saveDir.execute();

        /* Main Code Finish */
    }

    /* Start Open/Saved Document Error Check - Part B: Catch */

    catch (err) {
        alert("An image must be open and saved before running this script!");
    }
}

/* Finish Open/Saved Document Error Check - Part B: Catch */

 

 

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 ,
Nov 19, 2020 Nov 19, 2020

Copy link to clipboard

Copied

Sorry to bother you again, I'm getting this error... I don't recognise where it could be coming from. It doesn't relate to any of may paths I don't think. - 

Screen Shot 2020-11-19 at 19.45.40.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 ,
Nov 19, 2020 Nov 19, 2020

Copy link to clipboard

Copied

You saved the script as Rich Text Format - RTF! It must be plain text.

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 ,
Nov 19, 2020 Nov 19, 2020

Copy link to clipboard

Copied

LATEST

Save as plain text, not rich text.

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 ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

You have to create layer comps in the file for each layer combo, which is manual and adds to file size... Then use File > Export > Layer Comps to Files:

 

comps.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
Enthusiast ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

You might want to look at Variables and Data sets. It's easier to have you look it up in the help files rather than try to explain it in a post.

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 ,
Nov 02, 2020 Nov 02, 2020

Copy link to clipboard

Copied

Image Processor Pro Download 

My IPPVersions Actions Download 

Assign a F key to an action

JJMack

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 ,
Nov 03, 2020 Nov 03, 2020

Copy link to clipboard

Copied

Thank 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