Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 874
ownificate Avatar asked Jan 29 '26 14:01

ownificate


1 Answers

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
like image 167
Anna T. Avatar answered Feb 01 '26 07:02

Anna T.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!