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
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
Copy link to clipboard
Copied
Cssn you provide meaningful information for once?
Please post screenshots to clarify what goes awry.
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 😕
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
after the script this happens
change the original name to (file_ ")
This is not good for me
I wish the original name would remain.
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?
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
Copy link to clipboard
Copied
The problem is this before using the script the names are these
After I use the script it happens that it changes the name to so
This is not good for me
I wish the original name would remain.
Copy link to clipboard
Copied
I tested the code from DmitryEgorov’s last post and from this
I get this
There should’t be an open jpg after running the Script, so just to make sure: Did you run the last version?
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
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«:
Copy link to clipboard
Copied
The names seem to be honored, see screenshots from before and after running the Script:
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You can post, but with delay 😉
Copy link to clipboard
Copied
I tried with the names »mano.jpg« and »piede.jpg« and it worked as expected.
Copy link to clipboard
Copied
c_pfaffenbichler
Sorry I'm a goat
I made a trivial mistake.
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?