Firejs
Firejs

Reputation: 339

CMD - Copy files from multiple folders to one folder

I need copy lot of *.txt file from multiple folders to one.

I try use for exp.:

xcopy D:\Dokumenty\*.txt D:\final /sy

But this make 1:1 copy of folder. I need copy only files to a new folder.

Thanks for help.

Upvotes: 2

Views: 4994

Answers (2)

Paul
Paul

Reputation: 2710

You can also use wildcard (?*) in ROBOCOPY

usage: ROBOCOPY source destination [file [file]...] [options]

Transposing your example should look like this:

ROBOCOPY "D:\Dokumenty\" "D:\final" *.txt /S

Upvotes: 3

npocmaka
npocmaka

Reputation: 57242

for /r "D:\Dokumenty\" %%# in (*.txt) do copy /y "%%~f#" "D:\final"

Upvotes: 2

Related Questions