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

save all open documents in psd

Advocate ,
Mar 21, 2020 Mar 21, 2020

Copy link to clipboard

Copied

save all open documents in psd
in the same path as the original files

 

and rename the source file from test.jpg to test.psd

a.png

TOPICS
Actions and scripting

Views

5.4K

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

Guide , Mar 22, 2020 Mar 22, 2020

try this:

for (var i=0; i<app.documents.length; i++) {
    var doc = app.activeDocument = app.documents[i],
    f = doc.fullName
    doc.saveAs (File(f.path + "/" + decodeURI(f.name).replace(/\.\S+$/, "") + ".psd"))
    f.remove()
}

* i think I understand what the geppettol66959005 needs

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

Cssn you provide meaningful information for once? 

Please post screenshots to clarify what goes awry. 

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 ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

Loll, liking stopped to work for me, so I had to like you by saying it 🙂

 

Edit: it worked but with much delay.

 

Ps. I found another bad thing. During posting I could not go to next line (pressing Enter after smile face), so I removed it, pressed enter, added more text and in the highest line I used smile again 😕

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
Advocate ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

c_pfaffenbichler

the problem is this when I use this script

var startDisplayDialogs = app.displayDialogs
app.displayDialogs = DialogModes.NO
 
 
if (app.documents.length > 0) {
   var theFirst = app.activeDocument;
   var theDocs = app.documents;
 
// psd options;
psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = true;
psdOpts.layers = true;
psdOpts.spotColors = true;
 
   for (var m = 0; m < theDocs.length; m++) {
     var theDoc = theDocs[m];
     var num = m + 1;
     app.activeDocument = theDoc;
     theDoc.saveAs((new File("~/Desktop/file_" + num + ".psd")), psdOpts, false, Extension.LOWERCASE);
   };
   app.activeDocument = theFirst;
};

 

It happens to me that the name of the document changes
these are the original names

1.png

 

after the script this happens
change the original name to (file_ ")

2.png

 

This is not good for me
I wish the original name would remain.

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 ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

That that code did not what you wanted has been established. 

 

What was the problem with the code DmitryEgorov had provided? 

 

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
Guide ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

try this:

for (var i=0; i<app.documents.length; i++) {
    var doc = app.activeDocument = app.documents[i],
    f = doc.fullName
    doc.saveAs (File(f.path + "/" + decodeURI(f.name).replace(/\.\S+$/, "") + ".psd"))
    f.remove()
}

* i think I understand what the geppettol66959005 needs

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
Advocate ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

The problem is this before using the script the names are these

1.png

 

After I use the script it happens that it changes the name to so

2.png

 

This is not good for me
I wish the original name would remain.

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 ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

I tested the code from DmitryEgorov’s last post and from this 

Screenshot 2020-03-22 at 13.12.05.png

I get this 

Screenshot 2020-03-22 at 13.12.50.png

 

There should’t be an open jpg after running the Script, so just to make sure: Did you run the last 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
Advocate ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

I have run the latest version
now try to do this the files call them differently type

mano.jpg
piede.jpg
see what happens

another thing instead of opening 2 files open 3
and let me know what comes out

thank you for your time

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 ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

In the previous post I already showed what happend for 3 open files for me, this time for two with the names »mano.jpg« and »piede.jpg«: 

Screenshot 2020-03-22 at 13.29.44.pngScreenshot 2020-03-22 at 13.30.03.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 ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

The names seem to be honored, see screenshots from before and after running the Script: 

Screenshot 2020-03-22 at 13.29.44.pngScreenshot 2020-03-22 at 13.30.03.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 ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

Screenshot 2020-03-22 at 13.30.03.pngScreenshot 2020-03-22 at 13.29.44.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 ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

Seems I can’t post screenshots on this Forum at current, but I tried with the names »mano.jpg« and »piede.jpg« and it worked as expected. 

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 ,
Sep 08, 2020 Sep 08, 2020

Copy link to clipboard

Copied

You can post, but with delay 😉

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 ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

I tried with the names »mano.jpg« and »piede.jpg« and it worked as expected. 

Screenshot 2020-03-22 at 13.29.44.pngScreenshot 2020-03-22 at 13.30.03.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
Advocate ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

c_pfaffenbichler 

Sorry I'm a goat
I made a trivial mistake.

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 ,
Mar 22, 2020 Mar 22, 2020

Copy link to clipboard

Copied

OK, a fresh take on the original post:

 

 

 

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

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

        /* Main Code Start */
        for (var i = 0; i < app.documents.length; i++) {
            app.activeDocument = app.documents[i];
            var doc = app.activeDocument;
            var docName = doc.name.replace(/\.[^\.]+$/, '');
            var docPath = doc.path;
            
            // File Saving Code
            var saveFilePSD = new File(docPath + '/' + docName + '.psd');
            SavePSD(saveFilePSD);
        }

        // PSD Options
        function SavePSD(saveFilePSD) {
            psdSaveOptions = new PhotoshopSaveOptions();
            psdSaveOptions.embedColorProfile = true;
            psdSaveOptions.alphaChannels = true;
            psdSaveOptions.layers = true;
            psdSaveOptions.annotations = true;
            psdSaveOptions.spotColors = true;
            activeDocument.saveAs(saveFilePSD, psdSaveOptions, true, Extension.LOWERCASE);
        }
        
        // alert("All open documents saved as PSD to the source file path!");

        // Close All Open Docs
        /*
        while (app.documents.length) {
        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
        }
        // alert("All open documents closed!");
        */

        /* Main Code Finish */
    }

    /* Start Saved Document Error Check - Part B: Catch */
    catch (err) {
        alert("One or more previously saved documents must be open before running this script!");
    }
}
/* Finish Saved Document Error Check - Part B: Catch */

 

 

Note: I have commented out the code to close all open docs and the alerts to inform at key points.

 

EDIT: Late thought, I think that the OP wants the original open files to now be the PSD 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