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

Save copy incrementally with javascript in Photoshop

Engaged ,
Dec 24, 2021 Dec 24, 2021

The free Javascript "Save-Incrementally.jsx" for Adobe Illustrator 2022, Adobe Photoshop 2022 and Adobe InDesign 2022 or older versions saves the current saved document in the file format .ai, .psd or .indd and automatically adds a consecutive number to the file name. Thus, the file "Example.ai" becomes the file "Example-0001.ai", "Example-0002.ai" and so on; this works analogously for Photoshop and InDesign. This is also called "incremented" (continuous) saving. In this way, you can save individual steps in between and go back to an older version if necessary. The Javascript also works with older versions of Illustrator, Photoshop and InDesign.  

See my Behance profile or on my german website.

 

Have fun with it and merry christmas to all.

– jens

TOPICS
Actions and scripting , macOS , Windows
4.3K
Translate
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 , Sep 12, 2024 Sep 12, 2024

As it looks like @Parts4Arts is no longer active, you can download various versions of the scripts from my archive here:

 

https://www.dropbox.com/scl/fi/b1l8b03lqo5lz0g6exdrh/ai_ps_ind_Save-Incrementally.zip?rlkey=x7edz94n1ol4ho8gw6mhm9nyc&st=2glpr7cf&dl=0

 

There are other scripts on this forum to save incremental files, however they are only for Photoshop.

Translate
Adobe
Community Expert ,
Feb 05, 2025 Feb 05, 2025

@SandraPL wrote:

Hi guys,

was looking for this kind of function for a while now and happy to find something that is quite a good base.

BUT I was wondering if this script could be re-scripted that it's actually saving the files like a real incremental save would do it, so version up your file and NOT adding a new version counter at the ending.

Is this even possible?

 

Thanks a lot,

Sandra


 

 

If I understand what I think you're requesting, then no.

 

Scripts can't change how Photoshop file formats work. So we can't make a single file with various version states hidden in the file from which we can pick from. As Photoshop isn't a database, we can't track revisions using BLOBs either.

 

If you meant something else, then please spell it out in more detail.

Translate
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 Beginner ,
Feb 06, 2025 Feb 06, 2025

Hi @Stephen Marsh 

thanks for coming back on this request.

In detail: I would like to only version up e.g. from *_comp_v001 -> *_comp_v002.

The script is working instead like this *_comp_v001 -> *_comp_v001-0000.

 

Thanks,

Sandra

Translate
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 ,
Feb 06, 2025 Feb 06, 2025
quote

Hi @Stephen Marsh 

thanks for coming back on this request.

In detail: I would like to only version up e.g. from *_comp_v001 -> *_comp_v002.

The script is working instead like this *_comp_v001 -> *_comp_v001-0000.

 

Thanks,

Sandra


By @SandraPL


Ah, OK, I didn't understand you, thanks for the clarification.

 

Are you referring to the script originally shared, that is no longer available from the original link, which Is available from the personal archive that I shared via DropBox? If so, which script version number?

 

If you are referring to one of the alternatives offered in this topic thread, then which one?

Translate
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 Beginner ,
Feb 06, 2025 Feb 06, 2025

Downloaded the package that was shared from you on 12th Sep. 2024 and used the version 2.7 (ai_ps_id_ic_fm_Save-Incrementally_2-7).

Translate
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 ,
Feb 06, 2025 Feb 06, 2025
quote

Downloaded the package that was shared from you on 12th Sep. 2024 and used the version 2.7 (ai_ps_id_ic_fm_Save-Incrementally_2-7).


By @SandraPL


OK, that script is a big one, as it's for Ps/Ai/Id

 

Do you only need incremental saves in Photoshop? If so, only for PSD or other formats?

 

I'm guessing that it will be quicker and easier to use or modify a simpler script.

Translate
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 Beginner ,
Feb 06, 2025 Feb 06, 2025

For PS would be totally enough and for the formats psd and psb.

Translate
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 ,
Feb 07, 2025 Feb 07, 2025
quote

For PS would be totally enough and for the formats psd and psb.


By @SandraPL

 

OK, I'll look into this for you.

 

Translate
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 ,
Feb 07, 2025 Feb 07, 2025
quote

For PS would be totally enough and for the formats psd and psb.


By @SandraPL

 

Rather than modifying the original cross-application script, it was quicker to change an existing script.

 

Here it is for PSD:

 

/*
Save Incremental PSD Copies.jsx
Stephen Marsh
v1.0 - 7th February 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-copy-incrementally-with-javascript-in-photoshop/td-p/12616102/page/2
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-increments-and-save-embedded-colour-profile-jpg-and-png/td-p/14775268
*/

#target photoshop

saveIncrementally();

function saveIncrementally() {
    try {
        var saveFolder = app.activeDocument.path;
        if (!Folder(saveFolder).exists) {
            saveFolder = Folder.selectDialog("Select output folder");
            if (!saveFolder)
                return;
        }

        var docName = decodeURI(activeDocument.name);
        var saveName = docName.replace(/\.[^\.]+$/, ''); // Remove the file extension
        var suffix = zeroPad(1, 3); // Start number, Save suffix length
        var myFile = saveFolder + "/" + saveName + "_v" + suffix + ".psd";

        while (File(myFile).exists) {
            var suffixInteger = parseInt(suffix, 10);
            suffixInteger += 1;
            suffix = zeroPad(suffixInteger, 3);
            myFile = saveFolder + "/" + saveName + "_v" + suffix + ".psd";
        }

        savePSD(myFile);
        app.beep();

    } catch (e) {
        alert(e.toString() + "\nLine: " + e.line.toString());
    }

    // Helper functions

    function savePSD(saveFile) {
        var psdSaveOptions = new PhotoshopSaveOptions();
        psdSaveOptions.embedColorProfile = true;
        psdSaveOptions.alphaChannels = true;
        psdSaveOptions.layers = true;
        psdSaveOptions.annotations = true;
        psdSaveOptions.spotColors = true;
        app.activeDocument.saveAs(File(saveFile), psdSaveOptions, true); // false = save as | true = save a copy
    }

    function zeroPad(num, digit) {
        var tmp = num.toString();
        while (tmp.length < digit) { tmp = "0" + tmp; }
        return tmp;
    }

}

 

And here it is for PSB:

 

/*
Save Incremental PSB Copies.jsx
Stephen Marsh
v1.0 - 7th February 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-copy-incrementally-with-javascript-in-photoshop/td-p/12616102/page/2
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-increments-and-save-embedded-colour-profile-jpg-and-png/td-p/14775268
*/

#target photoshop

saveIncrementally();

function saveIncrementally() {
    try {
        var saveFolder = app.activeDocument.path;
        if (!Folder(saveFolder).exists) {
            saveFolder = Folder.selectDialog("Select output folder");
            if (!saveFolder)
                return;
        }

        var docName = decodeURI(activeDocument.name);
        var saveName = docName.replace(/\.[^\.]+$/, ''); // Remove the file extension
        var suffix = zeroPad(1, 3); // Start number, Save suffix length
        var myFile = saveFolder + "/" + saveName + "_v" + suffix + ".psb";

        while (File(myFile).exists) {
            var suffixInteger = parseInt(suffix, 10);
            suffixInteger += 1;
            suffix = zeroPad(suffixInteger, 3);
            var myFile = saveFolder + "/" + saveName + "_v" + suffix + ".psb";
        }

        savePSB();
        app.beep();

        function savePSB() {
            var s2t = function (s) {
                return app.stringIDToTypeID(s);
            };
            var descriptor = new ActionDescriptor();
            var descriptor2 = new ActionDescriptor();
            descriptor2.putBoolean(s2t("maximizeCompatibility"), true);
            descriptor.putObject(s2t("as"), s2t("largeDocumentFormat"), descriptor2);
            descriptor.putPath(s2t("in"), new File(myFile));
            descriptor.putBoolean(s2t("copy"), true); // false = save as | true = save a copy
            descriptor.putBoolean(s2t("lowerCase"), true);
            executeAction(s2t("save"), descriptor, DialogModes.NO);
        }


        function zeroPad(num, digit) {
            var tmp = num.toString();
            while (tmp.length < digit) { tmp = "0" + tmp; }
            return tmp;
        }


    } catch (e) {
        alert(e.toString() + "\nLine: " + e.line.toString());
    }
}  

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save as a plain text format file – .txt
  5. Rename the saved file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

 

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

 

Translate
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 Beginner ,
Feb 07, 2025 Feb 07, 2025

Thanks for taking a look and re-scripting.

Tested it right away and the file gets still an extension every time I save though, see screenshot.

Also it's only using v001 not counting up.

SandraPL_1-1738930716624.png

 

 

 

Translate
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 ,
Feb 07, 2025 Feb 07, 2025

@SandraPL 

 

You can't add your own manual incrementing filename as a base name and expect the script to carry on from there (unless the script was designed to do so, which it wasn't).

 

So, start with a base name without any manual version control digits, i.e.:

 

myFile.psd

 

The script will produce files as:

 

myFile_v001.psd

myFile_v002.psd

myFile_v003.psd

 

etc.

Translate
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 Beginner ,
Feb 07, 2025 Feb 07, 2025

Ok got it. That worked!
But that would mean the file/s need/s to be open till it's/they're finished.

Really appreciate your support.

Translate
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 ,
Feb 07, 2025 Feb 07, 2025
quote

Ok got it. That worked!
But that would mean the file/s need/s to be open till it's/they're finished.

Really appreciate your support.


By @SandraPL

 

These scripts are designed to create incremental backup copies of the working file for safety, leaving the working file open, as is. The working file needs to be manually saved as required by the user. The script could be updated to save the open working file each time that it creates an incremental copy.

 

It's possible to change the scripts so that a Save As is performed instead of Save a Copy, then the open document becomes the next incremented document. Is that what you are looking for?

Translate
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 ,
Feb 07, 2025 Feb 07, 2025

The following scripts are designed to Save As rather than Save a Copy.

 

PSD:

 

/*
Save As Incremental PSD Without Copy.jsx
Stephen Marsh
v1.0 - 8th February 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-copy-incrementally-with-javascript-in-photoshop/td-p/12616102/page/2
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-increments-and-save-embedded-colour-profile-jpg-and-png/td-p/14775268
*/

#target photoshop

saveIncrementally();

function saveIncrementally() {
    try {
        var saveFolder = app.activeDocument.path;
        if (!Folder(saveFolder).exists) {
            saveFolder = Folder.selectDialog("Select output folder");
            if (!saveFolder)
                return;
        }

        var docName = decodeURI(activeDocument.name);
        var saveName = docName.replace(/\.[^\.]+$/, ''); // Remove the file extension

        var suffixMatch = saveName.match(/_v(\d{3})$/);
        var suffix = suffixMatch ? suffixMatch[1] : zeroPad(1, 3); // Start number, Save suffix length

        if (suffixMatch) {
            saveName = saveName.replace(/_v\d{3}$/, ''); // Remove the existing suffix
        }

        var myFile = saveFolder + "/" + saveName + "_v" + suffix + ".psd";

        while (File(myFile).exists) {
            var suffixInteger = parseInt(suffix, 10);
            suffixInteger += 1;
            suffix = zeroPad(suffixInteger, 3);
            myFile = saveFolder + "/" + saveName + "_v" + suffix + ".psd";
        }

        savePSD(myFile);
        app.beep();

    } catch (e) {
        alert(e.toString() + "\nLine: " + e.line.toString());
    }

    // Helper functions

    function savePSD(saveFile) {
        var psdSaveOptions = new PhotoshopSaveOptions();
        psdSaveOptions.embedColorProfile = true;
        psdSaveOptions.alphaChannels = true;
        psdSaveOptions.layers = true;
        psdSaveOptions.annotations = true;
        psdSaveOptions.spotColors = true;
        app.activeDocument.saveAs(File(saveFile), psdSaveOptions, false); // false = save as | true = save a copy
    }

    function zeroPad(num, digit) {
        var tmp = num.toString();
        while (tmp.length < digit) { tmp = "0" + tmp; }
        return tmp;
    }

}

 

PSB:

 

/*
Save As Incremental PSB Without Copy.jsx
Stephen Marsh
v1.0 - 8th February 2025
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-copy-incrementally-with-javascript-in-photoshop/td-p/12616102/page/2
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-increments-and-save-embedded-colour-profile-jpg-and-png/td-p/14775268
*/

#target photoshop

saveIncrementally();

function saveIncrementally() {
    try {
        var saveFolder = app.activeDocument.path;
        if (!Folder(saveFolder).exists) {
            saveFolder = Folder.selectDialog("Select output folder");
            if (!saveFolder)
                return;
        }

        var docName = decodeURI(activeDocument.name);
        var saveName = docName.replace(/\.[^\.]+$/, ''); // Remove the file extension

        var suffixMatch = saveName.match(/_v(\d{3})$/);
        var suffix = suffixMatch ? suffixMatch[1] : zeroPad(1, 3); // Start number, Save suffix length

        if (suffixMatch) {
            saveName = saveName.replace(/_v\d{3}$/, ''); // Remove the existing suffix
        }

        var myFile = saveFolder + "/" + saveName + "_v" + suffix + ".psb";

        while (File(myFile).exists) {
            var suffixInteger = parseInt(suffix, 10);
            suffixInteger += 1;
            suffix = zeroPad(suffixInteger, 3);
            myFile = saveFolder + "/" + saveName + "_v" + suffix + ".psb";
        }

        savePSB();
        app.beep();

    } catch (e) {
        alert(e.toString() + "\nLine: " + e.line.toString());
    }

    // Helper functions

    function savePSB() {
        var s2t = function (s) {
            return app.stringIDToTypeID(s);
        };
        var descriptor = new ActionDescriptor();
        var descriptor2 = new ActionDescriptor();
        descriptor2.putBoolean(s2t("maximizeCompatibility"), true);
        descriptor.putObject(s2t("as"), s2t("largeDocumentFormat"), descriptor2);
        descriptor.putPath(s2t("in"), new File(myFile));
        descriptor.putBoolean(s2t("copy"), false); // false = save as | true = save a copy
        descriptor.putBoolean(s2t("lowerCase"), true);
        executeAction(s2t("save"), descriptor, DialogModes.NO);
    }

    function zeroPad(num, digit) {
        var tmp = num.toString();
        while (tmp.length < digit) { tmp = "0" + tmp; }
        return tmp;
    }

}

 

 

Translate
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 Beginner ,
Feb 08, 2025 Feb 08, 2025

Wow! Thanks that's awesome.

Exactly what I needed.

Thanks a ton for your work and quick turn around.

Translate
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 ,
Feb 08, 2025 Feb 08, 2025
LATEST
quote

Wow! Thanks that's awesome.

Exactly what I needed.

Thanks a ton for your work and quick turn around.


By @SandraPL


You're welcome!

Translate
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