How to print notepad++ files from command line\ Batch script.
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:
- open all the files in notepad++
- 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 :).
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.
Thanks for the input, Claudia.
‘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
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
but you provided /d:\%ComputerName%\CutePDF
the colon after d implies a computer device d.
print /d \YOUR_COMPUTER_NAME\CutePDF file1.c
throws an error : "Invalid switch - /d " .
Looks like command line is not recognizing the /d switch
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?