Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am new to powershell. I need to copy the whole folder structure from source to destination with filenames matching a pattern. I am doing the following. But it just copies the content in the root directory. For example

"E:\Workflow\mydirectory\file_3.30.xml"

does not get copied.

Here is my sequence of commands.

PS F:\Tools> $source="E:\Workflow"
PS F:\Tools> $destination="E:\3.30"
PS F:\Tools> $filter = [regex] "3.30.xml"
PS F:\Tools> $bin = Get-ChildItem -Path $source | Where-Object {$_.Name -match $filter}
PS F:\Tools> foreach ($item in $bin) {Copy-Item -Path $item.FullName -Destination $destination}
PS F:\Tools> foreach ($item in $bin) {Copy-Item -Path $item.FullName -Destination $destination -recurse}
share|improve this question
1  
Similar question [powershell-match-file-name-and-copy][1] [1]: stackoverflow.com/questions/6580725/… –  AEonAX Mar 29 at 7:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.