9 Replies Latest reply on Jan 29, 2018 2:23 PM by Thom Parker

    Newbie question re replace in string

    marceepoo Level 1

      I created an "action", to get a document's file and path by copying the following code (which I found somewhere on the web) into the console:

      /* Put script title here */

      console.show(); // open console

      console.clear(); // clear contents

      console.println(this.path); // display the current pdf's path

      The action generates the following text in the console output window:

      /F/VB/PythonAndPySide_Info/Python_Info/Introduction to Python Classes (Part 1 of 2) - Python Central.pdf

      I am beginning to try to learn javascript.  (I'm comfortable in vba and python, but I'm having trouble learning Acrobat javascript).

      I want to use javascript to (1) insert a ":" after the drive letter "F";  (2) remove the first forward slash ("/");  and (3) replace the replace the remaining forward slashes with back slashes.

      I tried unsuccessfully to do #3 first, but the following code produced an error message:

      /* Put script title here */

      console.show(); // open console

      console.clear(); // clear contents

      var fullname = this.path;

      fullname = fullname.replace("/", "\");

      console.println(fullname); // display the current pdf's path

      The error message was:

      SyntaxError: unterminated string literal

      5: at line 6

      I would very much appreciate any help anyone could give me.    I don't know where on the web I could learn this stuff.

       

                            Marc