• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to? copy /q ABC.txt + DEF.txt is appending hex 1A

#1
In this code .qa-vld and .csv are both semicolon-delimited plaintext files. The only control characters are CRLF. The qa-vld file is just a semi-delimited csv file with a header row. I have set Windows to open .qa-vld in Excel, although that happens later.

set m_vld="F:\CLIENT DOWNLOADS\TXE\a-Temp\TXE-MAIN.qa-vld"
set j_csv="F:\CLIENT DOWNLOADS\TXE\a-Temp\TXE-JUNK*.csv"

copy /Q /E %m_vld + %j_csv /A "%go_target_path\TXE-Import_%dashdate.qa-vld"

The source files both end in hex 0D 0A. But the target file ends in 0D 0A 1A and I'm trying to find out why. It did the same when I had the /A right after /E (which I found out isn't the correct syntax.)

Using TCC 22.00.40, Win 7 Pro 32-bit
 
#3
I may be remembering incorrectly, but I thought the EOF marker was automatic when you concatenate (with '+', even without /A) and that the /B was the way to prevent it. That's specifically mentioned in the help for COPY /B.
 
#4
You must be talking about:

====
/B If you use /B with a source filename, the entire file is copied; Ctrl-Z characters, if any, in the file are considered ordinary data to be copied. Using /B with a destination filename prevents addition of a Ctrl-Z to the end of the destination file. /B is the default unless source files are appended to the target file, or the target is a device, e.g., NUL.


This option applies to the filename immediately preceding it, and to all subsequent filenames until the file name preceding the next /A or /B option.
====
 
#5
Thanks! I hadn't read through the /B option in detail. I thought it was just "binary copy".

Obviously a case of:

"When all else fails READ THE INSTRUCTIONS!!!"

Me: "But all else hasn't failed yet ..."

By the way, I do need to be concerned about DOS compatibility--our main database program still is DOS ... (The decision maker is from the "If it hasn't totally crashed and burned and continued to burn despite being deluged with water, why replace it?" school of planning ...)
 
#7
Actually, I'm still running into problems with this. I modified the code and I'm still getting the Ctrl-Z added:

set m_vld="F:\CLIENT DOWNLOADS\TXE\a-Temp\TXE-MAIN.qa-vld"
set j_csv="F:\CLIENT DOWNLOADS\TXE\a-Temp\TXE-JUNK*.csv"

IFF EXIST %j_csv THEN
copy /Q /E %m_vld + %j_csv /A /B "%go_target_path\TXE-Import_%dashdate.qa-vld"
ELSE
copy /Q /E %m_vld /A /B "%go_target_path\TXE-Import_%dashdate.qa-vld"
ENDIFF


The only source file that existed was TXE-MAIN.qa-vld, so the ELSE code was triggered. Before running this I checked and TXE-MAIN.qa-vld ended with CRLF. The target file ends with CRLF and Ctrl-Z.

(I can't post the source files because they contain Protected Health Information that is confidential under federal law.)
 
#8
What about placing the /A before the source files?

From the CHM:
/A If you use /A with a source filename, the file will be copied up to, but not including, the first Control-Z (ASCII: 26) character in the file. If you use /A with a destination filename, a Control-Z will be added to the end of the file. /A is the default when appending files, or when the destination is a device like NUL, rather than a disk file.

/B If you use /B with a source filename, the entire file is copied; Ctrl-Z characters, if any, in the file are considered ordinary data to be copied. Using /B with a destination filename prevents addition of a Ctrl-Z to the end of the destination file. /B is the default unless source files are appended to the target file, or the target is a device, e.g., NUL.

So
copy /A source-files TO: /B target-files
???
 
Top Bottom