• 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.3K

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

Copy link to clipboard

Copied

You could try 

File > Scripts > Image Processor 

with »Save as PSD«. 

 

But as the psd-files are not the jpg-files renaming them does not seem to be an option. 

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

Copy link to clipboard

Copied

c_pfaffenbichler
I need a clean script because I have to put it in a quick button.

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

Copy link to clipboard

Copied

Say what? 

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

Copy link to clipboard

Copied

I have this
but it only works for jpg

i would like the same for psd.

 

var startDisplayDialogs = app.displayDialogs
app.displayDialogs = DialogModes.NO


if (app.documents.length > 0) {
   var theFirst = app.activeDocument;
   var theDocs = app.documents;

   jpgOpts = new JPEGSaveOptions( );
   jpgOpts.embedColorProfile = true;
   jpgOpts.formatOptions = FormatOptions.STANDARDBASELINE;
   jpgOpts.matte = MatteType.NONE;
   jpgOpts.quality = 12;

   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)), jpgOpts, false, Extension.LOWERCASE); 
   };
   app.activeDocument = theFirst;
};

 

 

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

Copy link to clipboard

Copied

It seems to me that your original post did not describe what you want by a long shot. 
Anyway, this should save the files with numbers to the Destop. 
 
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;
};

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

Copy link to clipboard

Copied

c_pfaffenbichler

The script is fine but the files are not saved in the original folder
in the same path as the original files

the files must keep the original name with the extension .psd

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

Copy link to clipboard

Copied

Then why did you say: »i would like the same for psd«? 

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Change theDocs.length to 1.

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

For me it worked.

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 ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

LATEST
for (var m = 0; m < 1; m++) {

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

 

for (var i=0; i<app.documents.length; i++) {
    var f = app.documents[i].fullName, 
    p = f.path, 
    n = decodeURI(f.name).replace(/\.\S+$/, "")
    app.documents[i].saveAs (File(p + "/" + n + ".psd"))
    f.remove() // removes original file, delete this line if it is not necessary
}

 

* unsaved documents that do not have a disk path will cause an error. In this case, the c_pfaffenbichler code is more suitable

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

Copy link to clipboard

Copied

Only for addition

var aDoc = activeDocument;
try {
    var docPath = aDoc.path;
} catch (e) {
    alert("not saved before");
    // code for saving
    }

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

Copy link to clipboard

Copied

... also document names may contain characters not supported by the current file system, there may be other errors while saving the file (read only or inaccessible folder), etc. - all this things needs to be processed...
I think that geppettol66959005 just does not need it.

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

Copy link to clipboard

Copied

AM solution:

 

sTT = stringIDToTypeID; (ref = new ActionReference())
.putProperty(sTT('property'), fR = sTT('fileReference'))
ref.putEnumerated(sTT('document'), sTT('ordinal'),
sTT('targetEnum')), executeActionGet(ref).hasKey(fR)

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

Copy link to clipboard

Copied

Great short code!

I was sure that if the necessary property not found, executeActionGet (ref) will cause an error...

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

Copy link to clipboard

Copied

Hi @Kukurykus,

nice code.

 

But i like the "normal" AM-coding much more.

var ref = new ActionReference ();
ref.putEnumerated (stringIDToTypeID ("document"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));
executeActionGet (ref).hasKey (stringIDToTypeID ("fileReference"));

 

There was a really long discussion in the old (Jive) Photoshop Scripting Forum.

https://community.adobe.com/#4917760

But this thread is archived (I think) and unfortunately is no longer available.

😞

 

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

Copy link to clipboard

Copied

... in any case, it is better  faster to get a separate property than the whole desc object ... 

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

Copy link to clipboard

Copied

What was that disscusion about?

 

btw like DmitryEgorov said you didn't use property at beginning that makes code much slower.

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

Copy link to clipboard

Copied

@Kukurykus wrote: "What was that disscusion about? …"

 

That was a very long and good discussion about: Was an image ever been saved before?

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

Copy link to clipboard

Copied

guys many answers but no valid solution?

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

Copy link to clipboard

Copied

Why not?

All necessary components are available - just not all possible scenarios.

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

Copy link to clipboard

Copied

then it is I who is incapable Because I haven't found the solution yet

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

Copy link to clipboard

Copied

What is wrong with this code?

for (var i=0; i<app.documents.length; i++) {
    var f = app.documents[i].fullName, 
    p = f.path, 
    n = decodeURI(f.name).replace(/\.\S+$/, "")
    app.documents[i].saveAs (File(p + "/" + n + ".psd"))
    f.remove() // removes original file, delete this line if it is not necessary
}

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

Dmitry

Your script doesn't save all open documents.

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