Solved

copy files from multiple subdirectories to one

Posted on 2007-04-05
5
609 Views
Last Modified: 2010-04-16
I thought I asked this the other day but something must have happened. I need to write a batch file script that will copy certain file types (*.doc for instance) from multiple subdirectories to another location. For instance:

Copy *.doc from c:\myfiles\all sub directories\*certain criteria*.doc to D:\permanent location

xcopy seems to always want to create the directory structure and subdirectories and i just want the files. Can someone point me in the right direction?
0
Comment
Question by:CUBLA1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 85

Expert Comment

by:oBdA
ID: 18860436
Try this; note the "/L" as argument for xcopy, which will only list the files it would copy otherwise, so that you can test it. Add other arguments as required.

@echo off
for /r "c:\myfiles\all sub directories" %%a in ("*certain criteria*.doc") do xcopy "%%a" "D:\permanent location\" /L
0
 

Author Comment

by:CUBLA1
ID: 18860546
Ok I receive the same result from when I tried your exact same solution after reading the FOR command instructions...and I just can't figure it out. I get:

Site"\Transcribers" was unexpected at this time

Now my source path is D:\FTP Site\Transcribers

The FTP has a space after it / before Site and I think this is causing problems but we cannot change it?
0
 

Author Comment

by:CUBLA1
ID: 18860557
This is what I have in my test.bat file:

@echo off
for /R "D:\"FTP Site"\Transcribers" %%a in (*LEC*.DOC) do xcopy "%%a" "D:\"FTP Site"\Dictators\LEC\#PENDING\" /L
0
 
LVL 85

Accepted Solution

by:
oBdA earned 250 total points
ID: 18861570
No need to add quotes all over the place; they're only necessary around the complete path.

@echo off
for /r "D:\FTP Site\Transcribers" %%a in ("*LEC*.DOC") do xcopy "%%a" "D:\FTP Site\Dictators\LEC\#PENDING\" /L
0
 

Author Comment

by:CUBLA1
ID: 18883516
that worked perfectly. thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn about cloud computing and its benefits for small business owners.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question