[Undocumented] Print

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

[Undocumented] Print

#1 Post by carlos » 10 Nov 2013 08:10

Hello. Doing some experiments I found a undocumented feature of print command. I'm sure that someone found this before, and really I did this many time ago, but today I found that this feature is not documented.

The documentation says that in /D:Printer parameter you need specify a PRINTER dispositive like LPT1,LPT2,LPT3,COM1,COM2,COM3,COM4 or network printer like \\ServerName\ShareName

But I found that you can specify a FILE on the printer.
This added a \0x0C character at the end of file.

Example:

Code: Select all

Echo.Hello>src.txt
Print /D:foo.out src.txt >NUL
notepad foo.out


or:

Code: Select all

Echo.Hello>src.txt
Print /D:MYFILE src.txt >NUL
notepad MYFILE


And this added a new utility feature: Added the \0x0C at the end of file and use \0x0C as character of end of file marker.

Also, create a file with the \0x0C character only:

Code: Select all

Type NUL > EMPTY.TXT
Print /D:CHAR.TXT EMPTY.TXT >NUL


Note:
If the the destination file exists print not overwrite the content, it not print to it. Is neccesary delete the destination file first.
Last edited by carlos on 11 Nov 2013 13:46, edited 7 times in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: [Undocumented] Print

#2 Post by foxidrive » 10 Nov 2013 08:27

It copies binary files to the foo.out too, and maintains the file except for the added last byte.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: [Undocumented] Print

#3 Post by carlos » 10 Nov 2013 22:04

I added a note about if the destination file exists.

Post Reply