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

JSX: Make document copy using Document.saveAs() without changing original filename

Explorer ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

I need to make document copy to perform some operations on it.

Main problem, when I use  Document.saveAs() is that I loose my original filename.

 

Is there any way to saving copy of existing document with modifying original filename?

TOPICS
Scripting

Views

649

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

Community Expert , Mar 23, 2023 Mar 23, 2023

That is unfortunate. Have you tried the action? Dynamic actions solve many problems.

Votes

Translate

Translate
Adobe
Explorer ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

* ...without modifying original filename

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 ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

how are you losing your original file name?

 

SaveAs(File) takes a file as argument 1, you provide the file name and location. 

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
Explorer ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

Yes. but this name will be used as default filename for future file saving.

I want to save copy, and original file name should be left unchanged.

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 ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

so you want to "save as" the current document, but you want it to save with the same name as the original document without overwriting the original file???

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
Explorer ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

No, i want to save with different name, but I want to keep original document name unchanged.

 

Main goal is that I need to make some work on document copy without making any changes to the opened window with the original document.

 

I already solved this by doing export to screen whole document as PDF. 

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 ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

nevermind. i think i know what you're asking.

 

you can save the current file name as a variable so you can still access it later... then at any point you can perform another save as and use the saved file name in your File() argument.

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
Explorer ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

This is not safe because opened document can has unsaved changes and user don't want to save these changes.

I described in the previous message how I solved this.

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 ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

you can use a script save the current document, save the name to a variable, save as (which makes a copy and doesnt alter the current document) then make whatever changes you want.

 

you can always re-open the original document with app.open(File(fileNameVariable));

 

per your previous comment about wanting to keep the original file name unchanged.... you can't do that with save as... saveAs only saves the current document with a new file name. there is no method for duplicating a document in the way you're asking... except to save the current document, save as to make a copy, then reopen the original document. or i guess you could use a script to duplicate everything to a new document and leave the original completely untouched. 

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 ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

in the UI, you can use File > Save a Copy

 

this will save a new copy of the current document without altering the current document's name or saved status. but the duplicate file would need to be manually opened after that

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 ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

Is it correct to mean that the problem is that when you do saveAs, the reference to the document is taken to the one you exported?

 

The solution to this problem is as follows.

  • Duplicate a file via File object before open document, open and edit it
  • Execute an action that recorded Save 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
Explorer ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

Yes, this is exact problem.

but I can't duplicate file, because I'm calling JSX from the CEP panel and file i already opened. 
Only ome way I found is to use export for screens call.

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 ,
Mar 23, 2023 Mar 23, 2023

Copy link to clipboard

Copied

LATEST

That is unfortunate. Have you tried the action? Dynamic actions solve many problems.

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