title: Need InDesign script to run on file open
body: <p>I have this javascript that saves a copy of a file. I need it to run automatically every time a file is opened and also save that copy to a specific folder. Here's what I have so far:</p>
  
  <pre><code>var myDoc = app.activeDocument;
  
  myDoc.save();
  
  var myFile = myDoc.fullName;
  
  var myDate = new Date;
  
  var mySuffix = "_Backup_" + myDate.getDate() + "_" + myDate.getMonth() +  "_" + myDate.getHours() + "-" + myDate.getMinutes() + "-" + myDate.getSeconds() +".indd"
  
  var myBaseName = myDoc.fullName.fsName.match(/(.*)\.[^\.]+$/)[1] ;
  
  var myNewFile = new File(myBaseName + mySuffix);
  
  myFile.copy(myNewFile);
  </code></pre>