Hey guys, new here.
I’ve been crawling all over the web for this one and I can’t seem to find an answer.
Here’s the scenario, I’ve got 1 folder with a mishmash of client names and a CSV with the names of those clients.
The catch is when I do an exact name to name search, I only get 23 results of the 1577 names in the CSV.
So here’s my latest stab at it:
Since not all the names are correct 100%, I figured let’s go with the first 7 characters. This gives me 0 results.
$a = Import-CSV C:\scripts\HelenClients.csv $a = @($a.Client) $a = $a | %{ $_.SubString(0,6) } $c = Get-ChildItem E:\Legal\ -include ($a) -recurse # | Where-Object {($_ -match $a)} ForEach($file in $c){ $dest = Split-Path -path $file.FullName -Parent | Split-path -NoQualifier #Copy-Item -path $file -recurse -Destination "e:\sorted\11\$dest" -force -Verbose }
$a = Import-CSV C:\scripts\HelenClients.csv $a = @($a.Client) #$a = $a | %{ $_.SubString(0,6) } $c = Get-ChildItem E:\Legal\ -include ($a) -recurse # | Where-Object {($_ -match $a)} ForEach($file in $c){ $dest = Split-Path -path $file.FullName -Parent | Split-path -NoQualifier #Copy-Item -path $file -recurse -Destination "e:\sorted\11\$dest" -force -Verbose }
Here’s the original, this nets me 27 results.
$a = Import-CSV C:\scripts\Clients.csv $a = @($a.Client) #$a = $a | %{ $_.SubString(0,6) } $c = Get-ChildItem E:\Legal\ -include ($a) -recurse # | Where-Object {$_ -match $a} ForEach($file in $c){ $dest = Split-Path -path $file.FullName -Parent | Split-path -NoQualifier #Copy-Item -path $file -recurse -Destination "e:\sorted\11\$dest" -force -Verbose }
So the files are kept in an order like so:
Animals ---Dogs ---Lots of Folders About Different Breeds ---PDFs and Docs that match the folder name ---Cats ---Lots of Folders About Different Breeds ---PDFs and Docs that match the folder name ---Penguins ---Lots of Folders About Different Breeds ---PDFs and Docs that match the folder name
Now the person who wrote these files was meticulous about following a naming convention.
An example would be
Dogs
Golden_Retriever
Golden_Retriever_Bones.pdf
Golden_Retriever_Hobbies.pdf
The issue now that I’m running into is that the client list has some issues matching up with what we’ve got. So a name to name search doesn’t work as stated before, so how about a partial search?
Should I loop it in a filter?
Please note that the target directory has 2996 items in it. I don’t want all of the items