0 Replies Latest reply on Jul 22, 2014 5:43 AM by Dapeamel

    backup indesign files

    Dapeamel Level 1

      Hello everyone

       

      I have a script there is a dialog box where you select indd files, you want to copy,

      you select a target, it creates a folder with same name as the folder from the selected indd files are located.

      also copying the .indd files there.

       

      example:

       

      Source 

      C:/342123/source/batch1/test.indd

      copy to /342123/inter/återvinning/

       

      Result.

      c:/342123/inter/återvinning/batch1/test.indd 

       

      the script also write a textfile with all the filenames of the copied indd files, the textfile been saved as the same folder as target.

      here is the problem..

       

      See code below:

       

      function copyfiles()
        {
        var myPath = (File($.fileName).parent.parent.parent.fullName);
        var jobName=(myPath); // filtrera bort jobbnummret för att kunna plocka parrent from aktiv path.
        var _files = new File(jobName).openDlg("Select indd files to copy","*.indd",true);
      
        TargetFolder= Folder.selectDialog("Välj Target var filerna skall hamna"),  //vart filen skall hamna
        _parent = _files[0].parent.toString().replace(_files[0].parent.parent,"");  
        new Folder(TargetFolder+ _parent).create();  //skapar mappen med namnet*
        var filenames = "";  
        var txtfile = new File(TargetFolder+ _parent + "/myFileLog.txt");  // skapar en txt fil i mappen som skapas
        for(var i=0;i<_files.length;i++)  
        {  
        _files[i].copy(new File(TargetFolder+ _parent + "/" + _files[i].name));  
        filenames +=_files[i].name + "\r";  
        }  
        txtfile.open('w');  
        txtfile.write(filenames);  
        txtfile.close();  
      }
      

       

      We have a filestructure which is always the same even for different jobs.

      I have wrote a script that creates structure the backup folderstructure

       

      See code below

       

      function Createfolders()
      {
                                   
      var myPath = (File($.fileName).parent.parent.parent.fullName).split("/Kommuni/LaRe/LareAUTO/"); // här är en array som består av två element, den splittas 
      var jobName=(myPath[1]); // sedan tar väljer jag andra elementet i arrayn (jobbnr) för att kunna plocka parrent from aktiv path.             
      
      
      // här börjar alla enskilda mappar
      new Folder("/Volumes/Arkiv/Laredoute_BACKUP/" + jobName + "/_project_BACKUP").create(); ;    
      new Folder("/Volumes/Arkiv/Laredoute_BACKUP/" + jobName + "/_project_BACKUP/TM_Big Book_BACKUP").create(); ;    
      new Folder("/Volumes/Arkiv/Laredoute_BACKUP/" + jobName + "/blåkopior i 34xxxx_BACKUP").create(); ;    
      new Folder("/Volumes/Arkiv/Laredoute_BACKUP/" + jobName + "/delivery_BACKUP").create(); ;    
      new Folder("/Volumes/Arkiv/Laredoute_BACKUP/" + jobName + "/delivery_BACKUP/PDF_BACKUP").create(); ;    
      new Folder("/Volumes/Arkiv/Laredoute_BACKUP/" + jobName + "/script_BACKUP").create(); ;   
                                   
      

       

       

      When we copy files it's always in the folderstructure,

      here is a example how it works now:

       

      Source

      C:/342123/inter/atervinning/batch1/test.indd 

       

      copy to

      C:/342123/inter/atervinning/

       

      I want my script to copy to this location to(my backup)

       

      copy to

      L:/inter/atervinning_backup/batch1/backupp_test.indd

       

      the script have always to know where the file is,

      and also the step

       


      here are few examples the way I want it to be

       

      source

      342123/inter/atervinning/batch3/

       

      target

      c:/342123/inter/efterredigering/

       

       

      result

      C:/342123/inter/efterredigering/batch3/

      L:/342123/inter/efteredigering/batch3/

       

      Example 2

       

      source

      342123/source/download/batch1/


      target

      342123/source/inter/

       

      result

      342123/source/inter/batch1/

      L:/34123/inter_backup/batch1/

       

       

       

      Does anyone have a solution?