Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Save Indesign File with Specific Name in Specific Location – JS

Return to Member Forum

  • Author
    Posts
    • #81037
      Marcin Ploch
      Member

      Hello,
      My workflow is:
      1. first I have 2 elements in a folder ZZZZ ( “xxxxx.INDT” and “yyyyy.XML”)
      2.then I open “xxxxx.INDT” and load “YYYY-yyyyy-YYYY.XML” into XML Root
      3. then do some things

      4. finaly I write a “yyyy.INDD” file in source Folder ZZZZ.

      For first 3 points I’ve written a code, ufff …. :-)

      I’m asking for help for writing a piece of code which will do point 4 :-)

      I’ve made a variable which is a string consist of “sliced” XML file name, but I don’t know how to make Indesign to write a file with the variable as their name in source folder.

      I know that probably it is very simple but I’m very beginner of JS and I’will be very grateful for any help :-)

      Best regards
      Marcin

    • #81038
      Peter Kahrel
      Participant
      myDocument.save (File('ZZZZ/yyyy.indd'));

      P.

    • #81039
      Peter Kahrel
      Participant

      If you plan to do any file handling, do read the chapter ‘File system access’ in the JavaScript Tools Guide. Start the ESTK, go to the Help menu, click ‘JaveScripts Tools Guide CC’.

      Peter

    • #81041
      Marcin Ploch
      Member

      Thank You Peter for the answer.
      Your code works nearly perfect for for my need.
      But there is one more thing ….

      I want Indesign to write a file to a Folder which I’ve chosen during opening a xxxxx.INDT
      Indesign KNOWS the path because alert from this line returns the right value of var SysFolder which is probably a string:

      var SysFolder = Folder.selectDialog(); alert(SysFolder)

      also I’ve made such variables:

      var PlikiIndt = SysFolder.getFiles(“*.indt”); //alert(PlikiIndt[0].name);
      var PlikiXML = SysFolder.getFiles(“*.xml”); //alert(PlikiXML[0].name);

      to save a file name I made another variable:

      var SaveName = “000_” + PlikiXML[0].name.slice(19,-24) + “_” + PlikiXML[0].name.slice(4,15) + “.indd”; alert(SaveName);
      doc.save (File(“/Users/marcinploch/Desktop/TEST” + SaveName));

      finaly indesign writes proper file name but in folder described by given string.

      The question is how to use path from SysFolder variable ??

      Regards
      Marcin

    • #81045
      Marcin Ploch
      Member

      Construction as below solves my problem :-)

      var SysFolder = Folder.selectDialog();

      var SaveFolder = SysFolder;
      var SaveName = SaveFolder + “/” + “000_” + PlikiXML[0].name.slice(19,-24) + “_” + PlikiXML[0].name.slice(4,15) + “.indd”;
      doc.save (File(SaveName));

      Marcin

    • #81046
      Peter Kahrel
      Participant

      Marcin,

      Folder.selectDialog();

      returns a Folder object, not a string.

      P.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.
Forum Ads