4 Replies Latest reply on Aug 4, 2015 2:47 AM by csm_phil

    File modified date and time compare with 24hrs back.

    csm_phil Level 4

      Hi All,

       

      I want to check the 1day before processed files, (e.g., the user run the tool time and check 24hrs back).

       

      I tried the the below JS code, Please check and guide me.

       

      var myFolder = File("~/Desktop");
      var myFiles = (myFolder.getFiles("*.eps"));
      for(i=0; i<myFiles.length; i++){
          var myFile = myFiles[i];
          var myFileDate = myFile.modified;
          var myCurDate = new Date();
          alert(DateCheck(myFileDate, myCurDate, myFile));
          }//for loop
      
      function DateCheck(DtVal1, DtVal2){
          var DtDiff;
          Date1 = new Date(DtVal1);
          Date2 = new Date(DtVal2);
          DaysDiff = Math.floor((Date1.getTime() - Date2.getTime())/(1000*60*60*24));
          if(DtDiff < 0){
          alert(myFile)
          return true;
          }
          else
          return false;
          }
      
      

       

      Thanks in advance.