ownificate
ownificate

Reputation: 63

Copy all txt files from all subfolders using xcopy

I have been tasked with copying all .txt files from the Program Files folder as well as all of it's subdirectories to another folder I have created. The script I have:

xcopy c:\"program files"\*\*.txt c:\temp\myfiles\lessons

doesn't want to work. What am I missing?

Upvotes: 3

Views: 14168

Answers (1)

Anna T.
Anna T.

Reputation: 161

If you want to maintain the folder structure,

xcopy /s "c:\program files\*.txt" c:\temp\myfiles\lessons

If not,

for /r "c:\program files" %a in (*.txt) do @copy /y "%a" c:\temp\myfiles\lessons

Upvotes: 14

Related Questions