944,030 Members | Top Members by Rank

Ad:
Feb 20th, 2007
0

MS Batch File Copying

Expand Post »
Hey everyone,

I am always having to copy DLLs from various folders for various reasons. So I thought if I had a .bat file to do it then it would save me bucket loads of time.

So is anybody here able to provide code to copy from several folders and place them into a single one?

The folders with the DLLs are along the lines of:

C:\FileManager\Implementation\bin\Debug\fileman.dll
C:\Viewer\Implementation\bin\Debug\viewer.dll
C:\Resource\Implementation\bin\Debug\resource.dll

And I would like them to be placed into a folder like:
C:\DllFiles

I have seen some code for copying files, but it just does a full copy of the folder. So is there a way to just get the specific DLLs (and not any referenced ones contained in Debug) I want instead of the other files MS Visual Studio creates in Debug?
Similar Threads
Reputation Points: 70
Solved Threads: 4
Junior Poster
RwCC is offline Offline
173 posts
since Jan 2006
Feb 22nd, 2007
0

Re: MS Batch File Copying

use copy or xcopy.

*.dll just copies files with the .dll extension.

http://www.computerhope.com/xcopyhlp.htm

Is a good resource.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
May 30th, 2007
0

Re: MS Batch File Copying

For the data set:

C:\FileManager\Implementation\bin\Debug\fileman.dll
C:\Viewer\Implementation\bin\Debug\viewer.dll
C:\Resource\Implementation\bin\Debug\resource.dll

Try something like:
@echo off
for /f %%G in ("FileManger","Viewer","Resource") do (
   for /f %%H in ("fileman","viewer","resource") do xcopy /c /h /v /y %%G\Implementation\bin\Debug\%%H.dll
)
Very quick and very very dirty. Need some error checking and should also put in a method to specify files from the command line or another file.

Gotchas are going to be the parenthesis and the strings to iterate through. Check out www.ss64.com/nt. Not a plug; just an excellent reference site for Windows and other OSes with command line access.
Reputation Points: 10
Solved Threads: 0
Light Poster
mittelgeek is offline Offline
37 posts
since Aug 2005
May 31st, 2007
0

Re: MS Batch File Copying

Click to Expand / Collapse  Quote originally posted by RwCC ...

The folders with the DLLs are along the lines of:

C:\FileManager\Implementation\bin\Debug\fileman.dll
C:\Viewer\Implementation\bin\Debug\viewer.dll
C:\Resource\Implementation\bin\Debug\resource.dll

And I would like them to be placed into a folder like:
C:\DllFiles
Here is a dead simple way, copy and paste this to your batch file and give it a try, then add any additional files you wish to copy to the batch file.

@echo off
copy C:\FileManager\Implementation\bin\Debug\fileman.dll C:\DllFiles\*.*
copy C:\Viewer\Implementation\bin\Debug\viewer.dll C:\DllFiles\*.*
copy C:\Resource\Implementation\bin\Debug\resource.dll C:\DllFiles\*.*

When you run this a second time you will probably be prompted to overwrite file. If you wish to avoid mess age add /Y to end of each copy line.

The echo off command just stops the command being displayed.

Have fun

Denis
Reputation Points: 22
Solved Threads: 19
Posting Whiz
DenisOxon is offline Offline
345 posts
since Jan 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: to convert string to integer value
Next Thread in Legacy and Other Languages Forum Timeline: palindrome program





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC