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

Oct 18, 2009
362
17
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
 
May 20, 2008
11,411
99
Syracuse, NY, USA
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.
 
Apr 2, 2011
1,441
10
54
North Carolina, USA
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.
====
 
Oct 18, 2009
362
17
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 ...)
 
Oct 18, 2009
362
17
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.)
 
Apr 2, 2011
1,441
10
54
North Carolina, USA
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
???
 
Oct 18, 2009
362
17
I found out the problem is that the /b has to follow the target filename.

For future reference, here's code that does copy multiple files only up to a Ctrl-Z and doesn't add a Ctrl-Z to the target file.

IFF EXIST %j_csv THEN
copy /Q /E %m_vld + %j_csv /A "%go_target_path\TXE-Import_%dashdate.qa-vld" /B
ELSE
copy /Q /E %m_vld /A "%go_target_path\TXE-Import_%dashdate.qa-vld" /B
ENDIFF
 
Similar threads
Thread starter Title Forum Replies Date
C Copy (sys) error Support 3
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
vefatica Copy/Paste anomaly Support 4
D Documentation Typo in COPY help Support 0
samintz COPY fails to copy from \\wsl$ Support 20
D Differences between TCC and CMD with COPY /b Support 4
fpefpe copy /u and timestamps Support 4
M Strange error messages from TCC in FTP copy Support 7
G TCMD crash when copy Support 3
Alpengreis How to? Copy DIRs with attributes ... Support 4
E Text copy bug Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6
fpefpe copy/cat Support 7
K copy /w slow relative to robocopy /mir Support 0
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
K "copy /z /w" command not deleting read-only files in destination Support 10
K copy changing destination current directory Support 1
D Keystroke to copy previous argument Support 3
A How to? Copy+Paste in TCMD tabs with Ctrl-Shift-Ins? Support 5
RChrismon How to? Copy TCMD.INI to New Version Support 7
R How to? Append files in multiple subfolders using copy? Support 8
Dick Johnson COPY /u (?) Support 9
fpefpe Documentation copy /u Support 7
D copy /g only shows transfer rate Support 1
J Error "Contents lost before copy" Support 3
B Can copy command concatenate multiple mp3 files Support 2
rps Documentation "Copy+Paste+run" question Support 2
kb6ojs Make /G parameter persistent in COPY/MOVE command? Support 4
fpefpe How to? copy / exclude Support 2
fpefpe robocopy -- copy /w Support 8
C copy /w /p prompts for deletion, but ... Support 3
D Fixed Copy Support 1
fpefpe Documentation copy/move using /c or /u Support 2
samintz WAD Copy/append adds a character Support 3
P Simple RegEx copy Support 9
fromano Fixed COPY ... TO ... crashing Support 3
Alpengreis How to? Copy & Paste without linebreak within TCMD Support 13
D COPY returns ERRORLEVEL 2 Support 5
mdwyer TCC 13 COPY: specified network name is no longer available. Support 5
CWBillow Copy a tree Support 17
J junction copy/move handling Support 6
vefatica Fixed COPY /S ftp://... Support 1
C WAD copy /u ftp local with Timeout? Support 5
D How to? Unregister a copy of Take command Support 1
vefatica FTP copy interrupted Support 2
C How to? COPY ftp folder query Support 7
R How to? TCC 16.03: copy a file to the clipboard? Support 10
jadaml Documentation Is COPY realy doesn't work for any HTTP and FTP? Support 3
T TCC control-C copy operation Support 3
Jay Sage Ctrl-C Not Working Reliably to Copy Screen Content Support 4

Similar threads