I have a folder with a 1000 files.
I want to use a csv file for 2 things
Field # 1 “Find” the string in the file name
Field # 2 “Destination” is the path the file should be copied too
There are multiple paths and my foreach loop is coping them to all the paths but not the path aligned with the find string Please Help
heres what I have so for
$csv = Import-Csv -Path "C:\Users\ldiskin\Desktop\Matrix2.CSV" $filepath = 'C:\SampleGroup' $entries = Get-ChildItem $filepath ForEach ($entry in $entries) { $destinations = $csv | Select-Object -ExpandProperty destination $find = $csv | select -ExpandProperty find $a = $entry.fullname ForEach ($f in $find) { If ($a -like "*$f*") { ForEach ($destination in $destinations) { Copy-Item $a $destination } }# end If } # foreach # 2 } # foreach main
The Csv file is attached