Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Subject: Search for folder and copy contents

Original Message
Name: JMidalo
Date: March 29, 2008 at 00:19:10 Pacific
Subject: Search for folder and copy contents
OS: VISTA
CPU/Ram: N/A
Model/Manufacturer: 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.



Report Offensive Message For Removal

Response Number 1
Name: cup
Date: March 29, 2008 at 01:35:37 Pacific
Subject: Search for folder and copy contents
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 2
Name: JMidalo
Date: March 29, 2008 at 14:28:39 Pacific
Subject: Search for folder and copy contents
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 3
Name: JMidalo
Date: March 30, 2008 at 01:13:36 Pacific
Subject: Search for folder and copy contents
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 4
Name: DosX
Date: April 2, 2008 at 08:48:17 Pacific
Subject: Search for folder and copy contents
Reply: (edit)
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 /?)


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Search for folder and copy contents

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software



Version Tracker Pro
Keep your software current and secure, effortlessly

Click Here for a Free Scan

Driver Agent
Automatically find the latest drivers for your computer.
Click Here for a Free Scan



The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC