16 Replies Latest reply on Apr 1, 2015 1:20 AM by Trevorׅ

    Issue with rename folder call by scriptMenuActions on Windows

    Ronald63 Level 4

      Hi,

       

      The script renameFolder.jsx works fine from ESTK and  double-clic from Script panel (MacOS- Windows 7 - InDesign CC 2014)

       

      //renameFolder.jsx
      
      var myFile=File.openDialog("Choose the file","*.indd",false);
      app.open(myFile);
      var docFolder = Folder(app.activeDocument.filePath);  
      app.activeDocument.close();
      var mResult= docFolder.rename(docFolder.name + "_OK" );
      alert(mResult);
      
      

       

      But when I call this script from my custom menu myMenu.jsx the function rename() doesn't works on Windows 7 - InDesign CC 2014 (works fine on MacOS - InDesign CC 2014)


      //myMenu.jsx
      
      #targetengine 'session'
      var myScriptFolder = Folder(app.activeScript.path);
      myFolder = myScriptFolder.parent + '/Scripts Panel/';
      //
      var mMenu = app.menus.item("$ID/Main").submenus.item("myMenu");
      if( mMenu != null) {mMenu.remove()};
      var mMenu = app.menus.item("$ID/Main").submenus.add("myMenu");
      // Title of menuItems
      var sma1Title = "Rename folder ...";
      // Create the Script Menu Action (SMA)
      var sma1 = app.scriptMenuActions.item(sma1Title);
          if( sma1 == null ) {sma1 = app.scriptMenuActions.add(sma1Title);}
      //
      var mMenuItem1 = mMenu.menuItems.add(sma1); 
      // Add an Event Listener
      sma1.addEventListener("onInvoke", RenameFolder, false);
      sma1.addEventListener("beforeDisplay", disableMenu, false);
      
      function RenameFolder(myEvent){
          app.doScript(File(myFolder + 'renameFolder.jsx'), ScriptLanguage.JAVASCRIPT);
      }
      
      function disableMenu(myEvent){
          if(app.documents.length > 0){
              sma1.enabled = true;
          }
          else{sma1.enabled = true;}
      }
      

       

      Thanks for your help ...

       

      Regards

      Ronald