Powershell: Copy document to sub folder of a sub folder with the name of "Clients"

Question

I am pretty new at Powershell so please be patient haha! But basically want to add a file to a folder called Claims within each sub folder of a directory.

This code works but saves it to every folder in the directory, when I only want to save it to the folders called "Claims".

Set-Executionpolicy -Scope CurrentUser -ExecutionPolicy UnRestricted $PathFrom = "File Path of folder where the document is held" $typeOfFiles = "File I want to save"

$PathTo = "Where I want to save it"

$copiedFiles = get-childitem -Path $PathFrom -Name -include $typeOfFiles -Recurse

$directories = Get-ChildItem -path $PathTo -Name -Exclude "." -recurse -force

foreach ($copiedFile in $copiedFiles) { copy-item (Join-Path $PathFrom $copiedFile) -destination $PathTo -Recurse -Force
}

foreach ($dir in $directories) { foreach ($copiedFile in $copiedFiles) { copy-item (Join-Path $PathFrom $copiedFile) -destination (Join-Path $PathTo $dir) -Recurse -Force
} }


Show source
| save   | directory   | subfolder   2016-12-29 17:12 0 Answers

Answers to Powershell: Copy document to sub folder of a sub folder with the name of "Clients" ( 0 )

Leave a reply to - Powershell: Copy document to sub folder of a sub folder with the name of "Clients"

◀ Go back