I have a situation while writing a dos batchs script. A tool I am using to calculate CRC (checksum) of a text string requires the text to be in a file. The data I am trying to get the CRC for is a filename, but when using a batch to put this filename into a text file to calculate CRC, the batch script naturally puts the line ending (CR/LF) and a blank line at the end. As this causes the CRC to be wrong, it is a problem.
Is there any way to get a batch script to write to a text file without appending a line ending? IE to output a single line unfinished to file?
-K.Barad
<nul set /p ".=text" > file
It's faster and safer than echo.|set /P ="text" > file
The nul redirection is faster than a pipe with echo.
(btw echo.
can fail).
The style of the quotes allowes to output also quotes.
But there are always restrictions!
Vista and Win7 have a "feature" to supress leading spaces, Tabs and CR's.
Xp can output text with leading spaces and so.
And it's not possible to begin the output text with an equal sign (results in a syntax error)
You could
echo.|set /P ="text" > file
source
Or directly pipe the text to the command line: echo "text" | checksum_program.exe
edit:
if you're using CRC32DOS, then you can use its command line option -c
to ignore CR
s.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With