Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

2.6K

Likes

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

Adobe Community Professional , 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

Likes

Translate

Translate
Adobe Community Professional ,
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. 

Likes

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.

Likes

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

Copy link to clipboard

Copied

Say what? 

Likes

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

 

 

Likes

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
Adobe Community Professional ,
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;
};

Likes

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

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

this script rename all documents. is it possible to rename and save a specific document?

Likes

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

Copy link to clipboard

Copied

is it possible to improve this script

Likes

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

Copy link to clipboard

Copied

Change theDocs.length to 1.

Likes

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

Copy link to clipboard

Copied

this does not work

Likes

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

Copy link to clipboard

Copied

For me it worked.

Likes

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

Copy link to clipboard

Copied

Sorry sir i think something is wrong i don't understand i don't use this code what to do

   for (var m = 0; m < theDocs.length to 1.  ) {
     var theDoc = theDocs[m];
     var num = m + 1;
     app.activeDocument = theDoc;

Likes

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

Copy link to clipboard

Copied

Sir, give me a true vision, I will be indebted to you

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

LATEST

thanks sir

Likes

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
Adobe Community Professional ,
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

Likes

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
Adobe Community Professional ,
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
    }

Likes

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
Adobe Community Professional ,
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.

Likes

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
Adobe Community Professional ,
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)

Likes

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
Adobe Community Professional ,
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...

Likes

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
Adobe Community Professional ,
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.

😞

 

Likes

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
Adobe Community Professional ,
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 ... 

Likes

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
Adobe Community Professional ,
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.

Likes

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
    • 1
    • 2