1.

Solve : Copying files from multiple directories into a sin?

Answer»

Hello All;

I am trying to create a batch FILE that will copy files from multiple directories into a single directory using wildcard. Example: I have a directory structure of c:\root\1111, c:\root\2222, c:\root\3333. I would like to copy c:\root\1111\*.txt, c:\root\2222\*.txt, c:\root\3333\*.txt to c:\newdir, and the next TIME I run it I may have a c:\root\4444, so I need to wild card the directory names as well. Of course the problem is if I use /S and xcopy I get the directory structure recreated, and if I don't I can't TRAVERSE the other directories.

Copy c:\root\*\*.txt c:\newdir is what I want but don't have.

I HOPE this is understanable and thaks in advance for any insight.If I understand this correctly, you want to traverse the directory structure on the input side, but on the output side all the files end up in the same directory. This may help:

Code: [Select]@echo off
for /f "tokens=* delims=" %%x in ('dir /a:-d /s /b c:\root\*\*.txt') do (
copy "%%x" c:\newdir
)

Good luck.



Discussion

No Comment Found