1 Reply Latest reply on May 3, 2011 7:05 AM by Bernd Alheit

    Create a new folder using field data

    soonermike01

      I'm running Adobe Pro 3D 8.1.0.  I have a script running in a combobox.  The script is working fine, but I want it to create a new folder if the folder doesn't exist then save the file into the new folder.  Below is my script for the combobox.

       

      -------------

       

      // build file name
      var site = this.getField("siteName").valueAsString;
      Date.prototype.defaultView=function(){
      var dd = this.getDate();
      var mm=this.getMonth()+1;
      var yyyy=this.getFullYear();
      return String(mm+"-"+dd+"-"+yyyy)
      }

       

      var today = new Date();
      var gmtHours = -today.getTimezoneOffset()/60;
      var cstHours = today.getUTCHours() + gmtHours;
      if(cstHours<10)cstHours='0'+cstHours;
      var min = today.getUTCMinutes();
      if(min<10)min='0'+min;
      var sec=today.getUTCSeconds();
      if(sec<10)sec='0'+sec;
      var timeStamp=today.defaultView() + "_" + cstHours + "-" + min + "-" + sec;
      var myFileName = site + "_" + timeStamp + ".pdf";
      // add folder name
      myFileName = "/f/file_test/" + myFileName
      myTrustedSpecialTaskFunc(this, myFileName);

       

      this.getField("docName").value = myFileName;

       

      -------

       

      I have tried the following within this script and on its own to try to create folders.  When I put it inside the above script, I do leave off the first line below.

       

      ----------

       

      var site = this.getField("siteName").valueAsString;
      myFolder = new Folder ("/f/Testing/" + site);
      if (myFolder.exists == false){
      myFolder.create();
      }

       

       

      ---------

       

       

      all help is appreciated!  Thanks!