Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm setting up a batch file for my work and I need some help. I want to find a specific folder on any of the drives on the computer, copy its contents, find another specific folder and paste the contents into that folder.
So say I got two folders in different drives.
C:\Example\Test\CONTENTS
D:\AnotherExample\AnotherTest\CONTENTSI would need to make a search for Test, once found, copy its contents and search for AnotherTest then paste the contents from Test into AnotherTest.
The reaosn I need to do the search is because people have their software installed in different places.
A bit complicated I know, well at least for me, any help is appreciated. Thanks.

You can get a dos prompt in Vista: just run cmd like on nt, 2K and xp. It is about the only good thing I can say about vista - there is a command line interface to help you when you can't find stuff by clicking.
Anyway isn't it just
xcopy C:\Example\Test\CONTENTS D:\AnotherExample\AnotherTest\CONTENTS /s/v
Use either for /r or dir /s to locate Test.

But how would you search for Test before doing the copying. I tried doing:
dir /s >> output.txt
FIND /c /i "Test" output.txtIt usually finds about 40 different folders with "Test" (Test is just the example name) and says --------OUTPUT.TXT: 41 FOUND
What would I do after this, how would I tell the program to narrow that search down to the 2 folders I need and then do a xcopy.
Thanks for the help.

Ok this is what I want the batch file to do:
Find directory named EXAMPLE. Save where that directory is to a variable. So that variable would read, lets say, C:\Folder1\Folder2\Example
Then copy that folder to the destination folder, lets say C:\DestinationFolder
I can find the directory by using:
dir find example
but then after that, I dont know how to save the path of the directory so I can xcopy it.
Thanks.

Try the following command:
for /r %1 in (example) do xcopy /E %1 C:\Folder1\Folder2\
I you want to use it in a batch file, you have to use %%1 instead of %1
You will probably need to tweak xcopy options to do what you want it to do (XCOPY /?)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |