why does help for copy mention /B so much in parameters?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
taripo
Posts: 228
Joined: 01 Aug 2011 13:48

why does help for copy mention /B so much in parameters?

#1 Post by taripo » 06 Oct 2024 01:11

why does help for copy mention /B so much in parameters?

Let's say I create a file , with an 1A(EOF) character in there. I can view it with the more command.

Code: Select all

C:\Users\User>echo 616263 | xxd -r -p >c:\crp\a.a

C:\Users\User>type c:\crp\a.a
abc
C:\Users\User>echo 6162631A646566 | xxd -r -p >c:\crp\a.a

C:\Users\User>type c:\crp\a.a
abc
C:\Users\User>more c:\crp\a.a
abc→def
So the file is

Code: Select all

C:\Users\User>xxd c:\crp\a.a
00000000: 6162 631a 6465 66                        abc.def
If I combine it with itself to make a new file g.g

C:\Users\User>copy /Y /B c:\crp\a.a + c:\crp\a.a g.g
c:\crp\a.a
c:\crp\a.a
1 file(s) copied.

C:\Users\User>

Then that works

Code: Select all

C:\Users\User>more g.g
abc→defabc→def

C:\Users\User>xxd g.g
00000000: 6162 631a 6465 6661 6263 1a64 6566       abc.defabc.def

C:\Users\User>
So why is it that the COPY /? documentation makes it look like you have to include /B lots of times

Like before all source files. And then after each source file and after the destination file

Code: Select all

COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B]
     [+ source [/A | /B] [+ ...]] [destination [/A | /B]]
It seems to me that it only needs to be put in once. That is, before all source files.
Last edited by aGerman on 06 Oct 2024 05:21, edited 1 time in total.
Reason: Just a typo that confused me at first: 0A(EOF) --> 1A(EOF)

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: why does help for copy mention /B so much in parameters?

#2 Post by aGerman » 06 Oct 2024 05:05

Options at the beginning apply to all sources and the destination. However, you can also define it for every source separately as well as for the destination. In this case you better really define /a or /b for every file as such options are seemingly taken over for the rest of the command if you leave them out.

Steffen

Code: Select all

Microsoft Windows [Version 10.0.22631.4249]
(c) Microsoft Corporation. Alle Rechte vorbehalten.

C:\Users\steffen\Desktop>more a.a
abc␦def

C:\Users\steffen\Desktop>copy /y /b a.a + a.a g.g
a.a
a.a
        1 Datei(en) kopiert.

C:\Users\steffen\Desktop>more g.g
abc␦defabc␦def

C:\Users\steffen\Desktop>copy /y a.a + a.a /b g.g
a.a
a.a
        1 Datei(en) kopiert.

C:\Users\steffen\Desktop>more g.g
abcabc␦def

C:\Users\steffen\Desktop>copy /y a.a /b + a.a g.g
a.a
a.a
        1 Datei(en) kopiert.

C:\Users\steffen\Desktop>more g.g
abc␦defabc␦def

C:\Users\steffen\Desktop>copy /y a.a /b + a.a /a g.g
a.a
a.a
        1 Datei(en) kopiert.

C:\Users\steffen\Desktop>more g.g
abc␦defabc␦

C:\Users\steffen\Desktop>copy /y a.a /b + a.a /a g.g /b
a.a
a.a
        1 Datei(en) kopiert.

C:\Users\steffen\Desktop>more g.g
abc␦defabc

C:\Users\steffen\Desktop>

Post Reply