Solved

copy files from multiple subdirectories to one

Posted on 2007-04-05
5
602 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
  • 3
  • 2
5 Comments
 
LVL 83

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 83

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found here: http://www.experts-exchang…
When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now