Computing.Net > Forums > Disk Operating System > Search for folder and copy contents

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Search for folder and copy contents

Reply to Message Icon

Name: JMidalo
Date: March 29, 2008 at 00:19:10 Pacific
OS: VISTA
CPU/Ram: N/A
Product: N/A
Comment:

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\CONTENTS

I 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.




Sponsored Link
Ads by Google

Response Number 1
Name: cup
Date: March 29, 2008 at 01:35:37 Pacific
Reply:

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.


0

Response Number 2
Name: JMidalo
Date: March 29, 2008 at 14:28:39 Pacific
Reply:

But how would you search for Test before doing the copying. I tried doing:

dir /s >> output.txt
FIND /c /i "Test" output.txt

It 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.


0

Response Number 3
Name: JMidalo
Date: March 30, 2008 at 01:13:36 Pacific
Reply:

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.


0

Response Number 4
Name: DosX
Date: April 2, 2008 at 08:48:17 Pacific
Reply:

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 /?)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Search for folder and copy contents

Copying folders www.computing.net/answers/dos/copying-folders/14763.html

Batch file - search for file www.computing.net/answers/dos/batch-file-search-for-file/12094.html

Searching for a file? www.computing.net/answers/dos/searching-for-a-file/14715.html