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?

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.


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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.