Skip to main content
Inspiring
January 29, 2024
Answered

remove copy when I duplicate document

  • January 29, 2024
  • 2 replies
  • 1643 views

there is a way to
remove copy when I duplicate document?

 

This topic has been closed for replies.
Correct answer Davide_Barranca12040269

@DavideBarranca , please forgive another intrusion; could you chime in on short/efficient UXP-code for this task? 


Hi @c.pfaffenbichler,

I'd do it like this:

 

 

const { app, core } = require("photoshop");
await core.executeAsModal( async () => {
  app.activeDocument.duplicate(app.activeDocument.name, true);
}, { commandName: "Duplicate with the same name" });

 

 

Which seems exactly what @Ciccillotto is using 👌
The boolean is for merged layers, like in ExtendScript, BTW.

 

 

2 replies

Chuck Uebele
Community Expert
Community Expert
January 29, 2024

In the preferences, under file handling, check the box that says: "Do not append 'copy' to filename when saving a copy."

Inspiring
January 29, 2024

I didn't explain myself well when I duplicate the document the word copy comes out.

Davide_Barranca12040269
Legend
January 30, 2024

@Davide_Barranca12040269 - Is the code for a panel or script? I saved the code from @Ciccillotto as a .psjs file, but nothing happened when run from Ps 2024 File > Scripts > Browse...

 

EDIT:

 

This works as .psjs:

 

 

app.activeDocument.duplicate(app.activeDocument.name, true);

 

or

 

app.activeDocument.duplicate(app.activeDocument.name.replace(/\.[^\.]+$/, ''), true);

 

 

 


Mine works if saved as a `.psjs`.
@Ciccillotto 's is missing the `commandName` prop in the options object (an empty one is fine, according to the docs) but lacks the function call to `DUPLICADOC()`

Davide Barranca - PS developer and authorwww.ps-scripting.com
Ged_Traynor
Community Expert
Community Expert
January 29, 2024

@Ciccillotto you can do that from the layers panel flyout menu, if that's what you mean.