Copy files form several directories to One

G

Guest

Hi;

I want to search a directory tree for all the *.txt files and copy them to a TXT directory.
I do NOT wish to copy the existing directory tree to the TXT directory. I have tried robocopy
and Xcopy, but they both recreate the Directory tree.

Any help would be appreciated.

M
 
P

Phil Robyn [MVP]

Mike said:
Hi;

I want to search a directory tree for all the *.txt files and copy them to a TXT directory.
I do NOT wish to copy the existing directory tree to the TXT directory. I have tried robocopy
and Xcopy, but they both recreate the Directory tree.

Any help would be appreciated.

M

From the CMD prompt:

for /f "tokens=*" %a in ('dir /s /b *.txt') do @echo copy "%a" \TXT

In a batch file, use '%%a' instead of '%a'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top