how to copy several files to somewhere?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Mohammad_Dos
Posts: 84
Joined: 08 Sep 2010 10:25
Location: Iran,Kashan
Contact:

how to copy several files to somewhere?

#1 Post by Mohammad_Dos » 10 May 2012 04:21

i want to copy two files for example c:\a.jpg and c:\a.txt to d:\

how to do it by 1 line command?
(not using "for" command)

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: how to copy several files to somewhere?

#2 Post by Fawers » 10 May 2012 04:28

Mohammad_Dos wrote:i want to copy two files for example c:\a.jpg and c:\a.txt to d:\

how to do it by 1 line command?
(not using "for" command)


In this example, this should work.

Code: Select all

copy /b C:\a.* D:\

Mohammad_Dos
Posts: 84
Joined: 08 Sep 2010 10:25
Location: Iran,Kashan
Contact:

Re: how to copy several files to somewhere?

#3 Post by Mohammad_Dos » 10 May 2012 04:40

i just want to copy these certain files. not any more. some other files with the same name "a" my be exist

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: how to copy several files to somewhere?

#4 Post by foxidrive » 10 May 2012 05:40

Mohammad_Dos wrote:i want to copy two files for example c:\a.jpg and c:\a.txt to d:\

how to do it by 1 line command?
(not using "for" command)



My question is why do you want that?

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: how to copy several files to somewhere?

#5 Post by Squashman » 10 May 2012 05:45

Only way I can see to do it is with a FOR command.
for /F "tokens=*" %G in ('dir /a-d /b C:\a.txt C:\a.jpg') do copy %G D:\

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: how to copy several files to somewhere?

#6 Post by foxidrive » 10 May 2012 05:47

He doesn't want to use the for command, Squashman.

The solution is very simple - and it seems to me like it is a question from an academic course.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: how to copy several files to somewhere?

#7 Post by Squashman » 10 May 2012 05:48

I suppose you could do this as well.
copy a.txt T:\ & copy a.jpg T:\

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: how to copy several files to somewhere?

#8 Post by foxidrive » 10 May 2012 05:56

Yeah. Maybe you should let him think for himself for such an elementary answer.

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: how to copy several files to somewhere?

#9 Post by Fawers » 10 May 2012 08:02

foxidrive wrote:and it seems to me like it is a question from an academic course.

I thought that as well.

Mohammad_Dos
Posts: 84
Joined: 08 Sep 2010 10:25
Location: Iran,Kashan
Contact:

Re: how to copy several files to somewhere?

#10 Post by Mohammad_Dos » 11 May 2012 04:54

thanks to all :wink:

Post Reply