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

automate save as or export with sequential file names

Community Beginner ,
Apr 22, 2017 Apr 22, 2017

Copy link to clipboard

Copied

Hi, I have a script that does some basic color manipulates within a selection.  I will run this script thousands of times to produce my graphic.  I would like to export a copy of my working file each time I run this script so that I can compile each step into an animation.  Naming the files manually each time the action is run would be really tedious and time consuming.

I've been reading about batch actions and integrating those file naming options, but I seem to be going in circles without any results.  Could someone point me in the right direction please?

Views

8.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 1 Correct answer

Community Expert , Apr 22, 2017 Apr 22, 2017

Check out this thread: Progressive Save As New Jpeg

Votes

Translate

Translate
Adobe
Community Expert ,
Apr 22, 2017 Apr 22, 2017

Copy link to clipboard

Copied

Are you talking about a Script (JS, VB or AS) or an Action?

In any case you may want to post over at

Photoshop Scripting

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 Beginner ,
Apr 22, 2017 Apr 22, 2017

Copy link to clipboard

Copied

sorry, i mean a photoshop action.  that was confusing of me.

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 ,
Apr 22, 2017 Apr 22, 2017

Copy link to clipboard

Copied

Check out this thread: Progressive Save As New Jpeg

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 Beginner ,
Apr 22, 2017 Apr 22, 2017

Copy link to clipboard

Copied

thanks, that looks promising

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
New Here ,
May 13, 2020 May 13, 2020

Copy link to clipboard

Copied

Has this thread been deleted? I can't access the link and it looks like it's just what I need!

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 ,
May 13, 2020 May 13, 2020

Copy link to clipboard

Copied

Adobe broke all of the old links when they changed the forum software. From memory there was also a cut-off on date as well. Such a shame for all that knowledge to be thrown out.

 

I tried searching for the exact topic title used in the link, however, nothing came up.

 

Are you just after an incremental file save script? Such as:

 

MyFile.jpg then after running the script you would get:

MyFile_01.jpg

MyFile_02.jpg

etc?

 

Please provide specific details on what you require, file format, exact options, filename suffix etc.

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
New Here ,
May 27, 2020 May 27, 2020

Copy link to clipboard

Copied

Thanks for getting back to me!

Yes, I need to export a piece I am painting digitally every minute or so to
create a full resolution time-lapse animation at the end.

Ideally, a timer that exports to jpg in sequential order:
1.jpg
2.jpg
3.jpg

But if not, defining an action where the file name increases by one
automatically so I don't have to deal with naming each time, would be great
as well.

If you have an idea for a function or script I'm open to it!

Thank you so much!

MAAYAN VISUALS




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 ,
May 27, 2020 May 27, 2020

Copy link to clipboard

Copied

Try the following code, I modified an old script to hopefully suit your requirements... By assigning a keyboard shortcut to the script, you can easily save your incremental files:

 

 

 

/*
automate save as or export with sequential file names
https://community.adobe.com/t5/photoshop/automate-save-as-or-export-with-sequential-file-names/td-p/9003836

2020 - Original script modified to remove the original filename from the sequential output file
https://forums.adobe.com/message/4453915#4453915
*/

#target photoshop

main();

function main() {
    if (!documents.length) return;
    var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
    try {
        var savePath = activeDocument.path;
    } catch (e) {
        alert("You must save this document first!");
    }
    var fileList = savePath.getFiles("*.jpg").sort().reverse();
    var Suffix = 0;
    if (fileList.length) {
        Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
    }
    Suffix = zeroPad(Suffix + 1, 3);
    //var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".jpg");
    var saveFile = File(savePath + "/" + Suffix + ".jpg");
    SaveJPEG(saveFile, 8); // JPEG compression level
}

function SaveJPEG(saveFile, jpegQuality) {
    jpgSaveOptions = new JPEGSaveOptions();
    jpgSaveOptions.embedColorProfile = true;
    jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgSaveOptions.matte = MatteType.NONE;
    jpgSaveOptions.quality = jpegQuality;
    activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
}

function zeroPad(n, s) {
    n = n.toString();
    while (n.length < s) n = '0' + n;
    return n;
}

 

 

 

Downloading and Installing Adobe 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
Community Expert ,
May 28, 2020 May 28, 2020

Copy link to clipboard

Copied

An Adobe Bridge reminder to save timer script here:

 

Reminder to save?

 

Leave the script running in the background in Bridge, it will pop-up an alert in Photoshop at regular intervals, reminding you to save!

 

________________

 

EDIT:

 

With a little modification, the reminder to save script can be altered to automatically run the script to save the incremental JPEG files.

 

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
New Here ,
Jun 01, 2020 Jun 01, 2020

Copy link to clipboard

Copied

Thanks so much- this is great! 

Would you have a recommendation for how to modify to automatically run the script to save the incremental JPEG files

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

Copy link to clipboard

Copied

Have you used the Bridge timer?

 

By default, it was set to pop up the alert in Photoshop every 3 minutes. Did you change it to 1 minute?

 

The potential issue with autosaves is what happens if the autosave does not work for some reason?

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
New Here ,
Jun 03, 2020 Jun 03, 2020

Copy link to clipboard

Copied

Yes I changed it to 1 minute.

Regarding autosaves-that is a good point. I know there is a disadvantage. I'm still interested in possibly integrating the two scripts and am not sure how to approach that.

 

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
Community Expert ,
Jun 03, 2020 Jun 03, 2020

Copy link to clipboard

Copied

1) Record the installed or browsed script into an action, here I have named the set "Incremental" and the action "Save":

 

atn.png

 

2) Here is the Bridge script, you will notice that it has a matching Photoshop command to play the Incremental set and Run action:

 

 

#target bridge;
if (BridgeTalk.appName == "bridge") {
    var psRem = new MenuElement("command", "PS Auto Timer - Incremental Save", "at the end of Tools");
}
psRem.onSelect = function () {
    var mins = 60000 * 1; // 1 minute 
    psReminder = function () {
        var bt = new BridgeTalk();
        bt.target = "photoshop";
        // Run action set 'Incremental' & action 'Save' which calls a recorded photoshop script 'incremental-jpeg-saves'
        bt.body = "if(documents.length) app.doAction('Save', 'Incremental') alert('File auto-saved via running Bridge script')";
        bt.send(4)
    }
    id = app.scheduleTask("psReminder()", mins, true);
    var win = new Window("palette", "Photoshop Reminder");
    win.bu1 = win.add("button", undefined, "Stop Reminder");
    win.bu1.onClick = function () {
        win.close(0);
        app.cancelTask(id);
    }
    win.show();
};

 

 

The previous code includes an alert to notify that the auto-save was performed. If you feel that this pop-up interrupts your painting workflow, change the following line of code:

 

 

bt.body = "if(documents.length) app.doAction('Save', 'Incremental') alert('File auto-saved via running Bridge script')";

 

 

To this:

 

 

bt.body = "if(documents.length) app.doAction('Save', 'Incremental')";

 

 

P.S. I'm not really happy with the reliance on a script being called from an action, which is then referenced from a Bridge script which then calls the Photoshop action and Photoshop script, however, I could not work out any other way of doing this, I have never edited BridgeTalk code before and it appears to be a bit pickier about syntax (I did try to use an @include without any luck).

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 Beginner ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

Hello

I tried this exact script.

I have a few images in a folder.

I want to make a different modification to each of them, but save them with the same settings.

I open the first image, do the modification and I want, use the script.

Image "001.jpg"created, great

Now I open the 2nd image, I do the modification I want and use the script.

Image "001.jpg"created and replaced the one that was created just before... Not what I want.

 

How can it see that "001.jpg" exists and not erase it but create "002.jpg" instead?

 

Thank you in advance for your help

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 ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

What version of Photoshop? What version of Bridge? What operating system and version?

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 Beginner ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

Hello

I am trying to use the script you posted on the 27 May 2020.

I copied and pasted it in Notpad and saved it as .jsx

 

I have no idea what Bridge is, I don't believe I need it.

 

Photoshop CC 2015

Windows 10

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 ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

OK, I posted two scripts, one with #target photoshop near the top of the code, another with #target bridge which provided a method to autosave in Photoshop using the sequential script at regular intervals.

 

There have been a number of scripts posted over the years for sequential saves, I'll look for some of the other scripts and post them later.

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 Beginner ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

Thank you!

I did try to find it by myself, and found a few itterations and even tried to mess around to try to:

- specify another Folder to save the new images

- and also to name all the new images "BG " (for Background) followed by 001, 002, 003

But I failed at everything, I have 0 knowledge on this, I can barely understand any line.

 

So, yes to try to make you understand what I want:

I have 100 images, on each of them I want to make specific resizing, so it can't be in the script, I do that part manually.

Once I have resized, I press a key (in the actions), and it runs the macro

 

The macro is only: save as jpeg 12 quality, same folder (or another), with renaming as "... 001"

Then, I open the next image, do the risizing manually again and press the key, and this one will be "... 002"

and so on

 

Hope I have been very accurate on what I want so there is no confusion ^^

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 ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

OK, I am just going to dump out all of the scripts that I have collected for making sequential/incremented saves. Let's just concentrate on finding one that works for you at a basic level. Perhaps they can then be modified further to do more.

 

Please post a threaded reply/comment against the script post, then it is obvious which one is being discussed.

 

Info on saving and installing scripts here:

 

Downloading and Installing Adobe 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
Community Expert ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

// Stephen_A_Marsh
// 05-01-2021
// Additional options & menu add
// Rombout Versluijs
// 14-01-2021

// Usage 
// - Because its being added to menu it can be hotkeyed
// - useFileName > true adds filename as a prefix
// - jpegQuality > sets save quality . range 1-12
// - formatOption > 1 Progressive
//                  2 Optimized Baseline
//                  3 Standard Baseline

/*
@@@BUILDINFO@@@ Quick Export as JPG Incremental.jsx 0.0.0.6
*/
/*
// BEGIN__HARVEST_EXCEPTION_ZSTRING
/*
<javascriptresource>
<name>$$$/JavaScripts/QuickExportAsJPGIncremental/Menu=Quick Export as JPG Incremental...</name>
 <category>scriptexport</category>
<menu>export</menu>
<enableinfo>true</enableinfo>
</javascriptresource>

// END__HARVEST_EXCEPTION_ZSTRING

*/
// alert(documents.length)

#target photoshop

var useFileName = false; // true - false
var jpegQuality = 10; // 1-12
var formatOption = 1; // 1-3         

/* Start Open/Saved Document Error Check - Part A: Try */
savedDoc();

function savedDoc() {
    // try {
        app.activeDocument.path;
        /* Finish Open/Saved Document Error Check - Part A: Try */

        /* Main Code Start */
        // https://forums.adobe.com/message/4453915#4453915
        main();

        function main() {
            if (!documents.length) return;
            var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
            var savePath = activeDocument.path;
            var fileList = [];
            if(useFileName){
                var fileList = savePath.getFiles(Name + "*.jpg").sort().reverse();
            } else {
                var fileList = savePath.getFiles("*.jpg").sort().reverse();
                var filtered = [];
                for( i in fileList){
                    var name = String(fileList[i]).split("/").pop(); // Get filename
                    name = name.slice(0,name.length-4); // Split extension from name
                    // alert(name+" "+!isNaN(name))
                    // https://stackoverflow.com/questions/651563/getting-the-last-element-of-a-split-string-array
                    if(!isNaN(name)) filtered.push(name); // Check if name is a number or not > fullname needs to be numbers
                }
            }
            var Suffix = 0;
            if (fileList.length) {
                if(useFileName){
                    Suffix = fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/); // Fix for mix of characters & numbers
                    Suffix = Number(String(Suffix).slice(String(Suffix).length-1,String(Suffix).length)); // Fix for Windows

                    // alert((fileList[0].name).slice(25,26))
                    // alert((fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/)).slice(fileList[0].name.length-5,fileList[0].name.length-4))
                    // alert((fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/)).slice(fileList[0].name.length-1,fileList[0].name.length))
                    // alert((fileList[0].name).slice(fileList[0].name.length-1,fileList[0].name.length))
                    // Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/)); // strips numbers when mixed
                    // Suffix = Number(fileList[0].name.match(/\d+$/)); // return true name even when mixed numbers and characters
                } else if ((!filtered[0] === undefined) || filtered[0]) {
                    Suffix = Number(filtered[0].replace(/\.[^\.]+$/, '').match(/\d+$/));
                }
            }
            Suffix = zeroPad(Suffix + 1, 3);
            Name = useFileName ? (Name +"_") : "";
            var saveFile = File(savePath + "/" + Name + Suffix + ".jpg");
            SaveJPEG(saveFile, jpegQuality, formatOption);
        }

        function SaveJPEG(saveFile, jpegQuality, formatOption) {
            jpgSaveOptions = new JPEGSaveOptions();
            jpgSaveOptions.embedColorProfile = true;
            if (formatOption === 1) {
                jpgSaveOptions.formatOptions = FormatOptions.PROGRESSIVE;
                jpgSaveOptions.scans = 3;
            } else if (formatOption === 2) {
                jpgSaveOptions.formatOptions = FormatOptions.OPTIMIZEDBASELINE;
            } else {
                jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
            }
            jpgSaveOptions.matte = MatteType.NONE;
            jpgSaveOptions.quality = Number(jpegQuality);
            activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
        }

        function zeroPad(n, s) {
            n = n.toString();
            while (n.length < s) n = '0' + n;
            return n;
        }
        /* Main Code Finish */
    // }

    /* Start Open/Saved Document Error Check - Part B: Catch */
    // catch (err) {
    //     alert(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
Community Expert ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

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 ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

#target photoshop

main();

function main() {
    if (!documents.length) return;
    var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
    try {
        var savePath = activeDocument.path;
    } catch (e) {
        alert("You must save this document first!");
    }
    var fileList = savePath.getFiles("*.jpg").sort().reverse();
    var Suffix = 0;
    if (fileList.length) {
        Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
    }
    Suffix = zeroPad(Suffix + 1, 3);
    //var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".jpg");
    var saveFile = File(savePath + "/" + Suffix + ".jpg");
    SaveJPEG(saveFile, 8); // JPEG compression level
}

function SaveJPEG(saveFile, jpegQuality) {
    jpgSaveOptions = new JPEGSaveOptions();
    jpgSaveOptions.embedColorProfile = true;
    jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    jpgSaveOptions.matte = MatteType.NONE;
    jpgSaveOptions.quality = jpegQuality;
    activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
}

function zeroPad(n, s) {
    n = n.toString();
    while (n.length < s) n = '0' + n;
    return n;
}

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 Beginner ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

Yes it is one of those that I tried yesterday.

I copied your whole script in your last post and tried, here how it went:

 

I opened my first image, resized it and ran the script you posted

It saved it as jpeg as 001, good

Then I pressed Del, to remove the image from Photoshop and dragged the next image, I resized it and ran the script again

It saved it as jpeg as 001 and so it unfortunately replaced the first newly created image

 

Somehow it does not detect "001", I think

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 ,
Jan 18, 2021 Jan 18, 2021

Copy link to clipboard

Copied

//community.adobe.com/t5/photoshop/looking-for-photoshop-script-that-gives-a-file-a-unique-name-saves-and-close/td-p/10998808
if (app.documents.length) {
    try { var f = app.activeDocument.fullName } catch (e) {
        var p = new Folder; f = p.selectDlg(); if (f) f = File(f + '/' + app.activeDocument.name)
    }

    if (f) {
        activeDocument.saveAs(createUniqueFileName(f))
        activeDocument.close()
    }
}

function createUniqueFileName(f) {
    var inPath = decodeURI(f.parent),
        inFile = decodeURI(f.name).replace(/\.[^\.]+$/, '').replace(/_\d+$/,''),
        inExt = '.psd',
        uniqueFileName = File(inPath + '/' + inFile + inExt),
        fileNumber = 1

    while (uniqueFileName.exists) {
        uniqueFileName = File(inPath + '/' + inFile + "_" + ('000' + fileNumber).slice(-3) + inExt)
        fileNumber++;
    }
    return uniqueFileName
}

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