Community
    • 登入

    How to print notepad++ files from command line\ Batch script.

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    6 貼文 2 Posters 9.4k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • AngelberryA
      Angelberry
      最後由 編輯

      Hi,

      I’m trying come up with a batch script that converts all the files in a folder to pdfs and saves them with the same filename along with its previous extension, using notepad++ and cutePdfWriter.

      Trying to do this in 2 steps:

      1. open all the files in notepad++
      2. Print each file and save it in pdf (eg: file1.c.pdf, file1.h.pdf)
        CutePdf is set as a default printer.

      Following is the batch script I used to open all the files in notepad++
      for /r %%x in (*.c) do (
      start “” “C:\Program Files (x86)\Notepad++\notepad++” “%%x”
      )
      However, not finding a command to ‘print’ all the opened files from the command line or a batch script unlike notepad
      Following command opens file1.c in notepad and prints the file in pdf.
      notepad /p file1.c

      notepad++ /p file1.c throws and error “C:\p doesnt exits. Create it?” and opens file1.c in notepad++.

      I aware of the plugin “Printall”, but this doesn’t suit my situation as I have to manually select the folder and files everytime.

      Thanks for your input in advance :).

      Claudia FrankC 1 條回覆 最後回覆 回覆 引用 0
      • Claudia FrankC
        Claudia Frank @Angelberry
        最後由 編輯

        @Angelberry

        npp doesn’t have such switch but is it needed to use npp anyway?
        I don’t know cutepdf but can’t you do something like

        for /r %%x in (*.c) do (
        print /d \\YOUR_COMPUTER_NAME\cutepdf "%%x".pdf
        )
        

        which of course means that you have shared the pdf printer as cutepdf.

        Please double check the print syntax.

        Cheers
        Claudia

        1 條回覆 最後回覆 回覆 引用 0
        • AngelberryA
          Angelberry
          最後由 編輯

          Thanks for the input, Claudia.

          The command,
          ‘print /d:\%ComputerName%\CutePDF file1.c’ does display
          “file1.c is currently being printed” on the cmd line but nothing happens.

          when checked “see what’s printing” option of the default printer (Control Panel\Hardware and Sound\Devices and Printers) an error is displayed.
          Document Name - Local Downlevel Document
          Status - Error - Printing

          Claudia FrankC 1 條回覆 最後回覆 回覆 引用 0
          • Claudia FrankC
            Claudia Frank @Angelberry
            最後由 編輯

            @Angelberry

            if you did it like you wrote than it is wrong.
            the command is, as far as I can remember,

            print /d \\YOUR_COMPUTER_NAME\cutepdf "%%x".pdf
            

            /d is a parameter for a printing device which is the share name of your pdf printer
            \YOUR_COMPUTER_NAME\cutepdf

            but you provided /d:\%ComputerName%\CutePDF
            the colon after d implies a computer device d.

            Cheers
            Claudia

            1 條回覆 最後回覆 回覆 引用 0
            • AngelberryA
              Angelberry
              最後由 編輯

              print /d \YOUR_COMPUTER_NAME\CutePDF file1.c

              throws an error : "Invalid switch - /d " .
              Looks like command line is not recognizing the /d switch

              Claudia FrankC 1 條回覆 最後回覆 回覆 引用 0
              • Claudia FrankC
                Claudia Frank @Angelberry
                最後由 編輯

                @Angelberry

                I’m sorry - my memory about this is wrong.
                Using google I found this which confirms your first syntax.

                Can you double check if you did the necessary steps described in the linked article?

                Cheers
                Claudia

                1 條回覆 最後回覆 回覆 引用 0
                • 第一個貼文
                  最後的貼文
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors