Solved

# Recursive Copy (xxcopy /sg) without xcopy

Posted on 2009-04-08
1,238 Views
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
Question by:weklica

LVL 2

Expert Comment

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

t0t0 earned 125 total points
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

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.