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

How to force-save a document?

Engaged ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

I've been scripting for a few years now, but it seems like there's no end to the way Adobe's products confound me. My latest conundrum is trying to save an open document to a network location without being prompted. This seems like a perfectly normal, easy problem to solve. InDesign CC 2017, however, chooses to make it difficult for me.

To save an open document, it's usually pretty easy.

var workDoc = app.open(new File("/Volumes/ArtDept/testfile.indd"), false);

/* Do some work on the file. */

workDoc.close(SaveOptions.YES);

To be clear, I'm on a Mac running Mac OS X 10.11.6 (El Capitan), and the file I'm working with is on a server on our LAN (Windows server, if it makes any difference).

The moment the `workDoc.close(SaveOptions.YES);` line is run, I am prompted on where to save the document. I want this script to run on hundreds of files, so I can't have it asking the user where to save each file; it should save over top of the original file without question. When working on a local HDD location, this isn't an issue. It seems that this only happens when working with a file on the server.

I have also tried using the `app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;` way of keeping the app from bugging the user, but that causes the script to halt at the `.close` method, stating that the user canceled the operation. It's the same as having the user hit "Cancel" in the Save dialog. So that won't work.

I need it to *always* overwrite the original .indd file, without question. How can I do this?

TOPICS
Scripting

Views

3.6K

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

Engaged , Dec 02, 2016 Dec 02, 2016

Sadly, when I tried your suggestion in Extendscript Toolkit, execution stops at the saving line with the message "Unsaved documents have no full name." I guess this seems to suggest that it's actually opening a copy of the document in the beginning, so it naturally has no reference on where to save it until I give it one.

Thus, when I change your suggestion to read:

workDoc.save(new File("/Volumes/ArtDept/testfile.indd"));

It appears to work fine. It just needed to be an absolute reference. (If tha

...

Votes

Translate

Translate
Community Expert ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

This always works for me:

workDoc.save(workDoc.fullName);

workDoc.close (SaveOptions.NO);

Peter

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 ,
Dec 02, 2016 Dec 02, 2016

Copy link to clipboard

Copied

Sadly, when I tried your suggestion in Extendscript Toolkit, execution stops at the saving line with the message "Unsaved documents have no full name." I guess this seems to suggest that it's actually opening a copy of the document in the beginning, so it naturally has no reference on where to save it until I give it one.

Thus, when I change your suggestion to read:

workDoc.save(new File("/Volumes/ArtDept/testfile.indd"));

It appears to work fine. It just needed to be an absolute reference. (If that's the right term.) Thanks for your assistance, pkahrel! Couldn't have done it without ya!

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 ,
Dec 03, 2016 Dec 03, 2016

Copy link to clipboard

Copied

This is strange. workDoc.fullName is an object of type File. This script:

alert (app.documents[0].fullName + '\r' + app.documents[0].fullName.constructor.name)

prints something like

/Volumes/ArtDept/testfile.indd

File

Would be interesting to see what the real full name is.

P.

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 ,
Dec 03, 2016 Dec 03, 2016

Copy link to clipboard

Copied

Hi all,

hm, yes, something is very odd here…


Maybe opening an InDesign file from a server volume means now something different compared to older versions?

Like opening a temp copy of a document?

Because InDesign CC 2017 now has a new feature when working with documents on a server and now is able to regain contact to a document on a server volume after the server was shut down and is available again after some time or if the working machine otherwise lost contact to the server and connects again after a while.

Regards,
Uwe

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 ,
Dec 05, 2016 Dec 05, 2016

Copy link to clipboard

Copied

pkahrel​: Yeah that line doesn't work for me; I still get the same error message.

Laubender​: My thoughts exactly. It must just be opening a copy of the original document. That would explain why it doesn't have a "full name" yet.

Also, 2 points that I neglected to bring up earlier:

  1. These files that are saved on the server and giving me grief were saved with an earlier version of InDesign. Perhaps CC 2015, 2014, or even the original CC. Some may go back as far as CS6, but I'm not sure if that's true.
  2. They were worked on and packaged locally, then copied to the server quite some time ago. When opening them, I get a warning message about 2 links being out of date and would I like to update them. I have newer versions of these files saved to my local HDD and, yes, some of the links have been changed in these new files. What's interesting is that the older files on the server have links that want to reference my local HDD. It sees those linked files (usually .icml files) on my HDD rather than the ones inside their own "/links" folder and sees they've changed; thus, the warning message to update links. However, if I open these same old server files from a different computer--one that does not have copies of them (newer or otherwise) on its local HDD--then the server files open up fine without any warning, and with all of their links referencing the proper ones in their respective "/links" folders. It's as though they are wired to look for some of their links on your local HDD first and, if it cannot find them, they have a fallback contingency to look in their own "/links" folder for those missing links.

Not sure if either of these has anything to do with the "opening a copy of a file" issue that I am apparently experiencing, but there you go.

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 ,
Dec 05, 2016 Dec 05, 2016

Copy link to clipboard

Copied

LATEST

Sturm359 wrote:

…

  1. These files that are saved on the server and giving me grief were saved with an earlier version of InDesign.

That's the culprit.

You have to save them first to get a value for fullName.

Regards,
Uwe

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