How to use dir and copy together to search directories and copy to a folder?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping
--
Chapters
00:00 How To Use Dir And Copy Together To Search Directories And Copy To A Folder?
00:35 Accepted Answer Score 12
01:03 Answer 2 Score 2
01:23 Thank you
--
Full question
https://superuser.com/questions/653924/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows #commandline
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping
--
Chapters
00:00 How To Use Dir And Copy Together To Search Directories And Copy To A Folder?
00:35 Accepted Answer Score 12
01:03 Answer 2 Score 2
01:23 Thank you
--
Full question
https://superuser.com/questions/653924/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows #commandline
#avk47
ACCEPTED ANSWER
Score 12
You could just use xcopy
:
xcopy /s foo???.txt g:\someplace
This will hold the directory structure.
If you don't want the directory structure you can do the following:
for /r %i in (foo???.txt) do xcopy /Y "%i" g:\someplace
If you are using this in a batchfile you should double the %
like this:
for /r %%i in (foo???.txt) do xcopy /Y "%%i" g:\someplace
ANSWER 2
Score 2
with Powershell u can run this:
cmd.exe /c dir *.txt /s /b | copy -Destination d:\md
part cmd.exe part Powershell bit more understandable but there overlapping