DosTips.com

A Forum all about DOS Batch
It is currently 27 Jul 2016 13:12

All times are UTC-06:00




Post new topic  Reply to topic  [ 10 posts ] 
Author Message
PostPosted: 10 May 2012 04:21 
Offline

Joined: 08 Sep 2010 10:25
Posts: 84
Location: Iran,Kashan
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)


Top
   
PostPosted: 10 May 2012 04:28 
Offline

Joined: 08 Apr 2012 17:11
Posts: 187
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:
copy /b C:\a.* D:\


Top
   
PostPosted: 10 May 2012 04:40 
Offline

Joined: 08 Sep 2010 10:25
Posts: 84
Location: Iran,Kashan
i just want to copy these certain files. not any more. some other files with the same name "a" my be exist


Top
   
PostPosted: 10 May 2012 05:40 
Online
Expert

Joined: 10 Feb 2012 02:20
Posts: 5813
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?


Top
   
PostPosted: 10 May 2012 05:45 
Offline
Expert

Joined: 23 Dec 2011 13:59
Posts: 3147
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:\


Top
   
PostPosted: 10 May 2012 05:47 
Online
Expert

Joined: 10 Feb 2012 02:20
Posts: 5813
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.


Top
   
PostPosted: 10 May 2012 05:48 
Offline
Expert

Joined: 23 Dec 2011 13:59
Posts: 3147
I suppose you could do this as well.
copy a.txt T:\ & copy a.jpg T:\


Top
   
PostPosted: 10 May 2012 05:56 
Online
Expert

Joined: 10 Feb 2012 02:20
Posts: 5813
Yeah. Maybe you should let him think for himself for such an elementary answer.


Top
   
PostPosted: 10 May 2012 08:02 
Offline

Joined: 08 Apr 2012 17:11
Posts: 187
foxidrive wrote:
and it seems to me like it is a question from an academic course.

I thought that as well.


Top
   
PostPosted: 11 May 2012 04:54 
Offline

Joined: 08 Sep 2010 10:25
Posts: 84
Location: Iran,Kashan
thanks to all :wink:


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 10 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Baidu [Spider], thefeduke and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited