Copy link to clipboard
Copied
Hello everyone,
I need script can rename the current document opening to what I need then save not save as, while run script open dialogue box to write name then ok rename but not open in new tab rename in the same document.
ahmada96002504 wrote:
How?
Something like this:
#target photoshop
(function () {
if (app.documents.length > 0) {
var origDoc = app.activeDocument;
var origDocName = origDoc.name.replace(/\.[^\.]+$/, '');
var newDocName = prompt("Enter New Filename:", origDocName);
if (newDocName === null) {
alert('Script cancelled!');
return;
}
origDoc.duplicate((newDocName), false);
...
Copy link to clipboard
Copied
No.
You may see the current document name changes when you use save as to save a new document for the first time. activeDocument.name is read only.
Copy link to clipboard
Copied
How i can get in script code?
I don't have knoqledge about script coding
Copy link to clipboard
Copied
You can't rename an open file. Either Save As or close it, rename, then re-open it.
Copy link to clipboard
Copied
The only other option not yet mentioned is to script a duplicate the doc and rename then close the original without saving. This would result in another file when saving. This is why renaming before opening was recommended.
Copy link to clipboard
Copied
How?
Copy link to clipboard
Copied
It will depend on the required file name, which you have not yet mentioned. Is it based on the original variable document name with a static prefix or suffix? Is it based on some file property or metadata property? Or will a promo be used so that you can type in the new name manually?
Copy link to clipboard
Copied
ahmada96002504 wrote:
How?
Something like this:
#target photoshop
(function () {
if (app.documents.length > 0) {
var origDoc = app.activeDocument;
var origDocName = origDoc.name.replace(/\.[^\.]+$/, '');
var newDocName = prompt("Enter New Filename:", origDocName);
if (newDocName === null) {
alert('Script cancelled!');
return;
}
origDoc.duplicate((newDocName), false);
origDoc.close(SaveOptions.DONOTSAVECHANGES);
} else {
alert('A document must be open to use this script!');
}
})
();
Copy link to clipboard
Copied
It work thanks,
It works fine.
Copy link to clipboard
Copied
You can duplicate the document with the name you want in Photoshop close the originals document and delete its backing file if one exists. The only place it exist then is in Photoshop with the document name you want. You should then save it to disk so there is a file containing the data.