Solved

Recursive Copy (xxcopy /sg) without xcopy

Posted on 2009-04-08
2
1,265 Views
Last Modified: 2012-05-06
I have xxcopy that works great.  If I say xxcopy /sg c:\test\*.txt c:\textfiles ... it will find text files that reside in all folders on the c:\test\* directories and copy them to textfiles (leaving folder structure behind.  How do I copy all types of a file from multiple folders to a single folder without installing xxcopy ?  Essentially, xcopy /s, but wihtout bringing over all of the folders?
0
Comment
Question by:weklica
2 Comments
 
LVL 2

Expert Comment

by:azaghlool
ID: 24103452
Hello,

It sounds like you need to create a batch file with several xcopy commands.  One for each source folder you wish to copy.
0
 
LVL 16

Accepted Solution

by:
t0t0 earned 125 total points
ID: 24105798
From a command line:

for /f "tokens=*" %a in ('dir /a-d /b /s "c:\SourceFolder\"') do @copy "%a" "c:\DestinationFolder\"


or in a batch file:

@echo off
for /f "tokens=*" %%a in ('dir /a-d /b /s "c:\SourceFolder\"') do copy "%%a" "c:\DestinationFolder\"


A problem will occur if two files have the same name....Can you guarentee every file will have a unique filename?


0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
avoiding the dashes in the sqlcmd output... 1 548
Batch file to delete a folder 5 72
Running Visio Macro from VBS File 3 87
Windows updates batch files 7 69
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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