• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

remove copy when I duplicate document

Engaged ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

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

 

TOPICS
Actions and scripting

Views

436

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 3 Correct answers

Community Expert , Jan 29, 2024 Jan 29, 2024

A script can do that:

 

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

 

or

 

activeDocument.duplicate(activeDocument.name, false);

Votes

Translate

Translate
Engaged , Jan 29, 2024 Jan 29, 2024

c.pfaffenbichler
Thanks for your help
I have successfully solved this problem

this is the solution if anyone wants to use it in the future

 

async function  DUPLICADOC() {
const ps = require('photoshop');
const myDoc = app.activeDocument;
const executeAsModal = ps.core.executeAsModal;
await executeAsModal(async () => {
  await ps.app.activeDocument.duplicate(myDoc.name, false)
}, {})
}

 

Votes

Translate

Translate
Engaged , Jan 30, 2024 Jan 30, 2024

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.

 

 

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

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

2024-01-29 12_50_21-Untitled-1 @ 50% (RGB_8).png

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

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

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
Engaged ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

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

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

A script can do that:

 

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

 

or

 

activeDocument.duplicate(activeDocument.name, false);

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

In the future please try to post meaningful screenshots including the pertinent Panels/dialogs to clarify what you are talking about. 

 

The » copy« does indeed not add a lot of relevant information but do you really just want the new, unsaved image to have the same name as the original?

Do you want to save it right away to some relative location, add some other name-element, …? 

 

And please remember to mark @Stephen_A_Marsh ’s post as »Correct Answer«. 

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
Engaged ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

c.pfaffenbichler
you're right but I was on a cell phone and couldn't add screenshots

Unfortunately, having little uxp documentation, I try to adapt the gaps with javascript
I'm trying to create a button in uxp that saves the document with a progressive number,
when I save as jpg it's fine
unfortunately when I want to save in psd this saves it with a progressive number like pippo.1.jpg
then if I save it again it does this to me
pippo.1_2.jpg then pippo.1_2_3.jpg and continue like this with each save.
so I'm trying to solve it this way
I duplicate the document, save inpsd and close the document,
this seems to work,

now I just need to figure out how to make this string work in uxp
activeDocument.duplicate(activeDocument.name.replace(/\.[^\.]+$/, ''), false);

 

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

I am not up-to-speed with UXP Scripting, still stuck with ESTK … hopefully someone else can chime in. 

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
Engaged ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

Unfortunately, even if uxp will be the future, I see it as very immature, the potential is there but for now javascript is superior in every way
for example this one in javascript is disarmingly simple
activeDocument.duplicate(activeDocument.name, false);
if I can get it to work with uxp it will definitely have a lot of excess code.

however this community is always kind and willing to help unlike the uxp forum which are reluctant to give info,

 

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 ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

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

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
Engaged ,
Jan 29, 2024 Jan 29, 2024

Copy link to clipboard

Copied

c.pfaffenbichler
Thanks for your help
I have successfully solved this problem

this is the solution if anyone wants to use it in the future

 

async function  DUPLICADOC() {
const ps = require('photoshop');
const myDoc = app.activeDocument;
const executeAsModal = ps.core.executeAsModal;
await executeAsModal(async () => {
  await ps.app.activeDocument.duplicate(myDoc.name, false)
}, {})
}

 

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
Engaged ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

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.

 

 

Davide Barranca - PS developer and author
www.ps-scripting.com

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 ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

@Davide_Barranca - 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);

 

 

 

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
Engaged ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

I have to use it for a panel I don't know if it works for psjs

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 ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

quote

I have to use it for a panel I don't know if it works for psjs


By @Ciccillotto

 

Thanks, I understand, for now I'm not interested in panel development – but I may be tempted to dip my toe into the pond with UXP scripting.

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
Engaged ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

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 author
www.ps-scripting.com

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 ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

Thanks David!

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
Engaged ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

@DavideBarranca I was wondering if there is a way to call back via uxp button a psjs file, I tried a couple of ways but it doesn't work, you have faced this problem.

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
Engaged ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

LATEST

@Ciccillotto I don't think so, but you can try to batchPlay the File > Script > Browse... and point to a `file:`, but be aware that there are manifest permissions to set, unless the file is in the plugin's sandbox. Adobe did something to restrict that Browse... call for JSX, IIRC, so it may or may not work (can't test now)

Davide Barranca - PS developer and author
www.ps-scripting.com

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 ,
Jan 30, 2024 Jan 30, 2024

Copy link to clipboard

Copied

Thank you! 

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