Skip to main content
Inspiring
June 1, 2020
Question

How to detect if project has unsaved changes?

  • June 1, 2020
  • 1 reply
  • 2499 views

I need to test if there are unsaved changes to the project in the After Effects application. Is there any way to do that? I get really close with this hacky solution -- save the project to a temp location and compare it to the current project:

 

function projectHasUnsavedChanges() {
  if (!app.project || !app.project.file) {
    return false;
  }
  var currentFile = app.project.file;
  // create_uuid pulled from https://stackoverflow.com/questions/105034/how-to-create-guid-uuid
  var tempProjectFile = new File(Folder.temp.fsName + '/' + create_uuid() + '.tmp.aep');
  app.project.save(tempProjectFile);
  var filesIdentical = byte_compare_files(tempProjectFile, currentFile);
  tempProjectFile.remove();
  return !filesIdentical;
}

 

This solution has a huge side-effect making it unacceptable. Basically whenever .save() is called, it changes the After Effects active project file to the saved location. Furthermore it adds the saved file to the recent history. Given I am just trying to do a test for unsaved changes, this doesn't work.

Are there any other options out there?

Thanks!

This topic has been closed for replies.

1 reply

Community Expert
June 1, 2020

AEGP_ProjectIsDirty ?

Devin-Author
Inspiring
June 1, 2020

Thank you for the reference. But how do I leverage this from ExtendScript, i.e. via ExternalObject or something?

Community Expert
June 1, 2020

either an ExternalObject or if you already have an AEGP running you could have it check the flag in idle hook and write it's status to a javascript global.