Does anyone know of a reliable way to determine whether an InDesign document is truly saved?
For example, I would expect the following AppleScript to work:
tell application id "com.adobe.InDesign"
try
set isModified to modified of theDoc
on error
set isModified to true
end try
end tell
However, I’ve run into cases where modified returns false (indicating the document is saved), but the asterisk (*) still appears in the document’s title bar next to the filename—suggesting there are unsaved changes.
This makes it difficult to confidently detect a “safe to proceed” state in automation workflows.
Has anyone found a more dependable method to confirm that a document is fully saved (and not just reporting modified = false prematurely)?
The asterisk is not a good indicator of the document’s saved state when scripting. Is the next step in the process another command in InDesign? If so, ID will wait for the save command to finish before proceeding, such as save and close.
Hi mingione,
In my case, there are no additional InDesign actions after the save completes—only a dialog from another application confirming that the document is done. What I’m trying to prevent is an operator moving on to another script before that “Done” confirmation appears.
We’ve run into situations where the document appears saved, but isn’t fully finished writing—especially when working from a network-synced location. If a subsequent save or action is triggered while the initial save is still in progress, it can lead to file corruption.
Because of that, I’m looking for a reliable way to confirm that the document is truly and fully saved—not just reporting as saved prematurely.
I don’t use indesign but supposedly the document has a saved property. So maybe try something like:
set isSaved to saved of theDoc
Of course, I don’t know exactly when it might become true in the saving process. Note, it is also possible that this only relates to whether there is a file somewhere.
Check the dictionary and see what it says about ‘saved’.
Hello mockman,
Unfortunately, the saved property only indicates whether the document has ever been saved since creation—it doesn’t confirm that it’s been saved after the most recent modifications.
The modified property generally works as expected, but we’ve encountered sporadic cases—likely related to documents stored in synced folders—where it returns false even though the document isn’t fully saved. If the document is manually closed at that point, the user is still prompted to save.
That’s exactly the scenario I’m trying to prevent: avoiding a save prompt after the script has already issued a save command.
The reason I say that the asterisk is a poor indicator of ‘saved’ is because it doesn’t update the ‘* file name’ if the document is in the background (and sometimes even if it’s in the foreground). I’m also seeing that after making a modification to the doc, the asterisk doesn’t appear immediately on my machine.
I’m testing this on a local machine so the save speed is fast. Try this on the network with a large file.
tell application id "com.adobe.InDesign"
save active document
if modified of active document is false then
beep -- The document has been saved
end if
end tell
If you’d like to check the file outside of ID, the byte length can be checked several times until it’s done writing.
tell application id "com.adobe.InDesign"
set theFile to get full name of active document
save active document
end tell
set finished to false
repeat until finished
set size1 to (get eof theFile)
delay 2 -- Wait 2 seconds
set size2 to (get eof theFile)
if size1 is equal to size2 then
set finished to true
end if
end repeat
display dialog "File is done writing."
Do I understand correctly that your script saves the document anyway?
Then wouldn’t close theDoc saving yes do what you need, that is close without a prompt plus ensure yet again that the doc is saved? Or do I misunderstand your scenario?
Hi Leo,
In theory, close theDoc saving yes would work if my only goal were to save and close the document. However, I need to run additional validation checks on the document after it has been saved by invoking a separate script—for example, checking for numerical expiration date strings and comparing them against a local file.
While some of these checks can be performed before the save, I still need a safety pass after the save completes. Because of that, this secondary “after-save” script is intended to operate on a document that has just been saved and should not need to trigger another save. Its primary purpose is to validate the document’s contents and, once everything checks out, quietly close the document.
However, there are occasional cases where this after-save script detects the document as modified and ends up requiring an additional save—even though the initial save already occurred. In other words, the first save appears to succeed, but if you attempt to immediately close the document, the operator is still prompted to save changes.
What makes this especially challenging is how difficult it is to reliably reproduce this false “saved” state.
It alternately amuses me and causes me to pull at my hair how some really basic stuff is so difficult.
Here is one other idea… have you considered doing something to check the file size (from inside a loop) and waiting until the size stops changing before proceeding to the next steps?