Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy multiple files using PowerShell

Tags:

powershell

I am currently learning how to use PowerShell. I was wondering if it would be possible for someone to tell me how to copy multiple text files from multiple sub-directories using the command line portion of PowerShell. I know how to do this in regular CMD and it looks something like this:

for /f "delims=" %F in ('dir \*.txt /s/b') do copy "%~F" "C:\test\" /Y

But obviously this does not work in PowerShell and needs a good bit of tweaking. Any help would be much appreciated. Thanks!

like image 357
scapegoat17 Avatar asked Dec 08 '22 15:12

scapegoat17


1 Answers

I was actually able to figure it out. This is how i did it:

get-childitem -path "SOURCE\PATH" -filter *.txt -recurse | copy-item -destination "DESTINATION\PATH" 

Thanks anyway!

like image 181
scapegoat17 Avatar answered Dec 18 '22 17:12

scapegoat17