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?
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
...Copy link to clipboard
Copied
This always works for me:
workDoc.save(workDoc.fullName);
workDoc.close (SaveOptions.NO);
Peter
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!
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.
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
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:
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.
Copy link to clipboard
Copied
Sturm359 wrote:
…
- 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