Cmd4Printer 0.2.0

Features

From picking files and setting up the printer to stamping pages, archiving and reporting — every stage, with a sample command for each.

01Inputs and batch sources

-src takes one or more sources, and you can mix them:

  • A single file, a folder (same as folder\*.*) or a wildcard such as D:\Contracts\2026-*.pdf; scansf:yes includes subfolders.
  • TXT lists: @list.txt with one path or wildcard per line; lines starting with # or ; are comments; UTF-8, UTF-16 and ANSI code pages are detected.
  • Excel/CSV lists: @list.xlsx or @list.csv with a #file column and optional #copies, #pages and #printer columns that override settings per row.
  • URLs: https://…, with user and password when a login is needed.
  • Standard input: @- reads the file list from a pipe.
  • Sorting: sort:name|date|type|size|path, add _d for descending; names sort naturally (2 before 10).
  • Safe scanning: min_age:120 only takes files last written more than 2 minutes ago; files locked by another program are skipped.
Command Prompt
cmd4printer -src "D:\Scans\*.pdf" "D:\Scans\*.jpg" -prn "Office A" -options scansf:yes sort:date min_age:120
Command Prompt
dir /b /s D:\Contracts\*.pdf | cmd4printer -src "@-" -prn "Office A"

02Supported formats

99 extensions in total. The table shows what handles each family and what it needs. cmd4printer -about lists the conversion engines available on your PC.

FamilyExtensionsNotes and requirements
PDFpdfBuilt-in PDFium engine; password-protected files (srcpwd) and embedded attachments
Common imagesjpg jpeg jpe jfif png bmp dib gif tif tiff emf wmfBuilt-in; multi-page TIFF prints every page
More image formatswebp heic heif avif jxr wdp hdp icoUses the Windows imaging codecs; HEIC/AVIF need the matching Windows image extension
TGAtgaBuilt-in
Photoshoppsd psbBuilt-in; prints the composite image
Text and source codetxt text log ini bat cmd c cpp h java js php ps1 ps1m py vb vbs ics vcf json xml sql csBuilt-in; font and size via -fls txt
XPSxps oxpsBuilt-in
CAD vector drawingsdxf plt hpgl hglBuilt-in, vector output (DWG/DWF are not supported; save as DXF or PDF)
Printer-language passthroughzpl prn pcl eplSent to the printer unchanged; the printer must understand the language (e.g. a ZPL label printer)
Web pages and URLshtm html xhtml mht mhtml svgRequires Microsoft Edge or Google Chrome
Markdownmd markdownRequires Edge or Chrome
EPUB e-booksepubRequires Edge or Chrome
Emaileml emlx msgRequires Edge or Chrome; attachments before/after the message or alone (attachments)
Word documentsdoc docx docm dot dotx dotm rtf odt wpsRequires Microsoft Word on the PC
Excel workbooksxls xlsx xlsm xlsb xlt xltx ods csvRequires Microsoft Excel on the PC
PowerPoint presentationsppt pptx pptm pps ppsx pot potx odpRequires Microsoft PowerPoint on the PC
Visio drawingsvsd vsdx vsdm vdxRequires Microsoft Visio on the PC
Publisher filespubRequires Microsoft Publisher on the PC
Tip: map other extensions to a known format on the “Extension aliases” page of the settings window, e.g. treat .lbl as ZPL passthrough; -engine picks the engine for a format.
Command Prompt
cmd4printer -src "C:\In\*.html" -prn "Office A" -engine file_format:html name:chrome

03Print settings

You wantParameter
Copies and collationcopies:3 collation:bydocuments
Duplex (long/short edge)duplex:vertical / duplex:horizontal
Color, grayscale or detect per pagecolor:grayscale / color:asindocument
Color by page rangecolor_pages:"1=color;2-last=grayscale"
Page rangepages:1,3,5-12 / pages:1,last
Paper by name/ID or matched to the page sizepapersize:A4 / papersize:-2
Tray, and tray by page rangetray:"Tray 2" / pssp:"1=Tray 1;2-last=Tray 2"
Orientation and auto-rotationorient:landscape / auto_rotation:cw
Scalingscale:fit / scale:zoom zoom_percent:90
Reverse orderrevpo:reverse
Skip blank pagesskip_empty:yes
One print job for all files (strict order)spjob:yes spjob_name:"…"
Split large jobssplit_every:200 / max_copies_per_job:50
Command Prompt
cmd4printer -src "D:\Contracts\*.pdf" -prn "Office A" -props copies:2 duplex:vertical color:grayscale pages:1-3 papersize:A4 tray:"Tray 2"

Tray and paper names depend on the printer — look them up first:

Command Prompt
cmd4printer -prn "Office A" -options showtraylist showpapersizelist

04Page operations: watermarks, barcodes, rotate, crop

-oper can be repeated, and each operation has its own page range (pages:). Available operations:

OperationPurpose
textwatermarkText watermark: font, size, color with alpha, angle, background, border; text may contain macros
watermarkImage watermark: PNG/JPG/BMP/GIF or the first page of a PDF, with opacity and layer
barcode22 symbologies: QR, Data Matrix, PDF417, Code 128, EAN-13, GS1 and more
rotateRotate; multiples of 90° keep PDF pages vector
cropCrop by margins, by rectangle or automatically
resizeResize to a size, six fit modes
rasterizeConvert to an image, a fix for problematic files

Macros for text and barcodes: {SrcFileName}, {SrcFileExt}, {SrcFilePath}, {SrcFilePageNo}, {SrcFilePageCount}, {FileIndex}, {FileCount}, {Date:yyyy-MM-dd}, {Time}, {UserName}, {ComputerName}, {PrinterName}, {env:NAME}.

Command Prompt
cmd4printer -src "D:\Drawings\*.pdf" -prn "Office A" -oper textwatermark text:"INTERNAL USE ONLY" fontsize:40 halign:center valign:center angle:45 color:"r:120,g:120,b:120,a:90" bgcolor:"#FFFFFF00" -oper textwatermark text:"Page {SrcFilePageNo} of {SrcFilePageCount}" halign:right valign:bottom fontsize:9

05N-up and booklets

-multipps places several pages on one sheet: 1–10 across and 1–10 down, with gaps, frames and page order; start_next_doc_on_new_sheet:no lets the next file continue on the same sheet. Booklet mode puts two pages on each side, pads the page count to a multiple of four and switches to short-edge duplex, so the stack folds into reading order; bind on the left, right or top.

4-up
cmd4printer -src "D:\Handouts\*.pdf" -prn "Office A" -multipps enabled:yes hor_pages:2 ver_pages:2 draw_frame:yes
Booklet
cmd4printer -src "D:\Manual.pdf" -prn "Office A" -multipps enabled:yes booklet:yes booklet_binding:left

06Cover and service pages

-spops cover:yes prints a cover sheet before each file, which makes sorting output on a shared printer easy. Use the built-in Blank, Filename, Filename with app logo or FileInfo templates, your own HTML (@cover.html, macros allowed), or drag elements around in the cover designer of the settings window and save a .cover file. folder_cover:yes adds a sheet whenever a new subfolder starts, ending:yes a summary page at the end of the batch. The cover is its own print job by default; same_job:yes joins it to the document.

Command Prompt
cmd4printer -src "@D:\Daily\list.txt" -prn "Office A" -props spjob:yes -spops cover:yes template:FileInfo ending:yes
The cover designer in the settings window
The cover designer in the settings window

07Post-processing

-postproc handles source files that printed and files that failed separately: copy, move or delete. Rename the target with macros (for example, add the date); conflict decides between rename, overwrite and skip; passed_delsf:yes removes subfolders left empty. A dry run never post-processes anything.

Command Prompt
cmd4printer -src "D:\Inbox\*.*" -prn "Office A" -postproc passed:move passed_dir:"D:\Printed" passed_name:"{Date:yyyyMMdd}-{SrcFileName}.{SrcFileExt}" failed:move failed_dir:"D:\Failed"

08Logs, statistics and exit codes

  • log:yes logpath:"…" logverbosity:regular: one XML event log per run.
  • pres:"…": plain-text list of results; unprinted_files_log:"…": failed files, ready to reprint as an @list.
  • -stat report_folder:"…" format:csv: statistics with pages, sheets and color/grayscale page counts.
  • output:json or jsonl: results as JSON on standard output for your programs.
  • export_path:"…": logs, settings and system information in a ZIP (passwords masked) for support requests.
Exit codeMeaningWhat to do
0All files were submitted to the print queue—
1Internal errorExport logs with -options export_path and contact support
2Usage error: wrong switch, value or syntaxRead the allowed values and the example in the error message
3Environment problem: printer, tray, paper or files not found, or the print spooler is stoppedCheck names with showprnlist / showtraylist
4Some files failed; the others were submittedCheck unprinted_files_log and reprint only those files
5Submit result unknown; the job may already be queuedCheck the print queue before reprinting
6Cancelled (Ctrl+C)—
Command Prompt
cmd4printer -src "D:\Inbox\*.*" -prn "Office A" -options log:yes logpath:"D:\PrintLogs" unprinted_files_log:"D:\PrintLogs\failed.txt" -stat report_folder:"D:\PrintLogs" format:csv

09Automation: scheduled tasks, scripts, command files

  • silent:yes alerts:no: no console output and no pop-ups, ideal for scheduled tasks.
  • dryrun:yes: plan only — nothing is printed or moved.
  • timeout:300: give up on a file after 5 minutes of conversion and printing and move on.
  • runscript:"…" script_params:"{SrcFilePath}": run a script before each file; a non-zero result marks the file as failed.
  • -cmdlines commands.txt: run several commands from a file, one per line — handy for very long commands or several printers.
  • -inipath profile.ini: a different set of defaults for each task.
  • outputfile:"…": with a virtual printer, write the output straight to a file for testing.
Command Prompt
cmd4printer -src "D:\Test\*.*" -prn "Microsoft Print to PDF" -options outputfile:"D:\TestOut\{SrcFileName}.pdf"

See scheduled printing and exit codes in batch files for complete examples.

10Settings window

Run cmd4printer -ini to open the settings window and save your usual parameters as defaults; anything not given on the command line then uses them. There are six pages: Common (copies, color, orientation, duplex, paper, pages, UI language), Advanced, Print engines, Extension aliases, Watermarks (live preview drawn by the same code that prints) and the Cover page designer. Settings can be exported and imported to copy them between PCs.

The Common page of the settings window
The Common page of the settings window

Defaults are layered in this order, later ones winning: built-in defaults → %ProgramData%\Cmd4Printer\Cmd4Printer.ini (all users) → %APPDATA%\Cmd4Printer\Cmd4Printer.ini (current user) → the file given with -inipath → the command line.

Command Prompt
cmd4printer -ini