0 Replies Latest reply on Sep 23, 2016 3:40 AM by tpk1982

    Modification Date changed

    tpk1982 Level 4

      Hi,

       

      I am trying to create folders and copy the file what i pick. The below code is working fine in Indesign. I need this to work in Illustrator as well. Could you please help me?

       

      Original Thread: Modification Date changed

       

      function myfolder(){  
          var _files = File.openDialog("Select Indesign/Illustrator file","*",true);  
      if(_files==null){return;}  
      myFolder = Folder.selectDialog("Choose Main folder to created subfolders");      
      if(myFolder==null){return;}  
      _parent = _files[0].parent.toString().replace(_files[0].parent.parent,"");    
      var mygetname=prompt("Please enter the Event ID","");  
      if(mygetname==null){return;}  
      var myartname=prompt("Please enter the Part Number","");  
      if(myartname==null){return;}  
      var myartnamew=myartname+"_Aa"  
      new Folder(myFolder + "/" + mygetname).create();    
      new Folder(myFolder + "/" + mygetname+ "/OT"+ "/" + myartnamew).create();    
      new Folder(myFolder + "/" + mygetname+ "/OT"+ "/" + myartnamew+ "/Art").create();  
      new Folder(myFolder + "/" + mygetname+ "/OT"+ "/" + myartnamew +"/Soft").create();  
      mymodified=_files[0].modified;
      myfile=new File(myFolder + "/" + mygetname+ "/OT"+ "/" + myartnamew+ "/Art"+ "/"+myartnamew+ "/" );
      _files[0].copy(new File(myFolder + "/" + mygetname+ "/OT"+ "/" + myartnamew+ "/Art"+ "/"+myartnamew+ "/" ));  
      changeDate(myfile.fsName, mymodified);
      }  
      myfolder();
      
      
      function changeDate(file, date) {  
          var year, month, dayOfMonth, hours, minutes, command, appleDate;  
        
          year = 1900 + date.getYear();  
          month = pad(1 + date.getMonth());  
          dayOfMonth = pad(date.getDate());  
          hours = pad(date.getHours());  
          minutes = pad(date.getMinutes());  
          appleDate = "" + year + month + dayOfMonth + hours + minutes;  
        
          command = ["try",  
              "do shell script \"touch -ft " + appleDate + " '" + file + "'\"",  
              "end try"  
          ].join('\n');  
          try {  
              app.doScript(command, ScriptLanguage.APPLESCRIPT_LANGUAGE);  
          } catch (e) { $.writeln(command + "\n" + e); }  
          return undefined;  
        
          function pad(value, digits) {  
              value = "" + value;  
              digits = digits || 2;  
              var padding = new Array(digits + 1).join("0");  
              return (padding + value).slice(value.length);  
          }  
      }  
        
      
      

       

       

      Thanks,

      K