usage of copy command in Dos

September 16, 2011 at 05:52:59
Specs: Windows XP SP3
how can i copy 2 files in one time in DOS copy command,do not tell me by xcopy command instead,thanks!

See More: usage of copy command in Dos

Report •

#1
September 16, 2011 at 05:57:33
Please, specify location and name of the two files and the common destination.

Report •

#2
September 16, 2011 at 09:28:40
i want to copy simultaneously 2 files of Sent.txt and News.txt in drive A to drive B resulted in the original 2 files of Sent.txt and News.txt but not a file of combination of the 2 oringinal files.

Report •

#3
September 16, 2011 at 11:07:11
As far as I know the only way to use the COPY command to copy more than one file is to use wildcards. copy a:\*.txt b: will copy those two files from the root directory on a: to the default directory on b: but it will also copy all other files with a .txt extension.

If there are files on a: you don't want copied something like copy a:\?e??.txt b: may filter them out. That command copies all four letter named txt files where 'e' is the second character.


Report •

Related Solutions

#4
September 16, 2011 at 11:44:21
Dont forget the /V to verify the copy is good.

Good Luck - Keep us posted.


Report •

#5
September 16, 2011 at 12:34:17
DAVEINCAPS solution is very good. Another way is to code

for %j in (Sent News) do copy /V A:\%j.txt B:\

Use %%j if part of a batch script, type %j if entered at prompt.

Report •

#6
September 17, 2011 at 10:56:44
if i copy the 2 files of autoexec.bat and config.sys simultaneously with Copy command from a:\ to b:\ ,how can i do? thanks!

Report •

#7
September 17, 2011 at 12:25:28

for %j in (autoexec.bat config.sys) do copy /V A:\%j B:\

Now, please, would you explain why you want to copy simultaneously these two files instead of coding two separate statements?

The files are actually copied sequentially, never concurrently, even in a multitasking system as Windows. More be aware to copy autoexec.bat and config.sys does not suffice to make the B: diskette bootable. You need other files and commands.


Report •

#8
September 19, 2011 at 12:03:29
would you please explain in more detail the use of %j if batch script since i type %j if and press enter at drive A prompt, the response to me is that bad command or file name. When i type %j (autoexec.bat config.sys) and press enter the response is the same as before. By the way i have learned a few year ago, more than 2 files could be copied by Copy command in Dos with a syntax seemed like that copy A:\""autoexec.bat" " config.sys" "fdisk.exe"" B:\ but i think i should forgot something in the syntax.However,much thanks for your help!

Report •

#9
September 19, 2011 at 13:09:17
First of all rhe copy command in native DOS can copy just one file but you use wild cards, i.e. sprcial symbols like * or ? to mask string of characters. E.G.

copy A:\config.sys B: copies just config.sys
copy A:\config.* B: copies config.sys, config.txt and all files named config whatever extension they have.

Since you want to copy autoexec.bat and config.sys wild cards can't do the job. You have to use a compound statement usually coded in a batch script.

for %j in (autoexec.bat config.sys) do copy /V A:\%j B:\

At prompt you have to type exactly the above line to execute the command. Otherwise if you enter the following line

for %%j in (autoexec.bat config.sys) do @copy /V A:\%%j B:\

into a text file and save it as e.g. mycopy.bat in A: then typing at prompt

mycopy

run the command stored in the file avoiding repetitive annoying typing.

I hope I was clear, but read again my post #7 since the usual way to accomplish what you wish is just to type

copy A:\autoexec.bat B:
copy A:\config.sys B:


under whatever Microsoft operating system. Do not build a nuclear power plant to take a cup of coffee.


Report •

Ask Question