3

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?

X-Istence
  • 16,324
  • 6
  • 57
  • 74
ownificate
  • 63
  • 1
  • 1
  • 5

1 Answers1

14

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
Anna T.
  • 161
  • 8