Skip to main content
Inspiring
October 25, 2012
Question

How to check if current project is saved?

  • October 25, 2012
  • 2 replies
  • 1579 views

Howdy folks,

Is there a command to see if the current project has unsaved changes?

Looking at the AE scripting guide, I see app.project.save() and the app.project.file object, but I don't see a way to check if the scene has unsaved changes.  I would like to check this before my script runs to protect the user from loosing any changes they haven't saved.   Of course I can just do a app.project.save() before the script does anything, but the user might not want to save their current changes.  Gotta protect the users!

I tried inspecting the app.project.file object in ExtendScript Toolkit, but it doesn't appear to have any methods.

thanks for your help!

-Andy

This topic has been closed for replies.

2 replies

Alex White
Legend
October 25, 2012

How about comparing system date:

dObj = new Date();

alert(dObj.toString());

With modified project date + time?

fRef = File.openDialog("Select","");

y = (fRef.modified).getFullYear();

m = (fRef.modified).getMonth()+1;

d = (fRef.modified).getDate();

alert(y+"/"+m+"/"+d);  // adjust hours and etc

AndyR_Author
Inspiring
October 31, 2012

Thanks for the responses.  Seems like my best option is to pop up a confirmation dialog, informing the user that the current scene will be saved, and ask if they would like to continue:

    var r=confirm("Caution, the current scene will be saved. Do you want to continue?");

    if (!r){

        return;

    }

This is less than ideal, since asking users questions like this makes them nervous.  I suspect in most situations, the scene will already be saved, so the confirmation box just makes the script appear buggy or not well written. :\

Dan Ebberts
Community Expert
Community Expert
October 25, 2012

I recall requesting this, but as far as I know, that info isn't available to scripting.

Dan

Alan_AEDScripts
Inspiring
October 25, 2012

As a horrible work around - you could save a copy of the project and then compare the filesize of app.project.file to that other file.

If the byte count was different - could we assume there were changes??