Basically what I'm trying to do is:I'm pulling information from a .csv spreadsheet that contains a list of files that I need. The problem is, the directory they are in contains 16,000+ files! I only need around 4600 of them (as the spreadsheet column only contains that many). I've actually gotten all that part of the code figured out... but where I'm running into issues is when it gets to the "Copy-Item" portion of my code. It runs fine until it hits files that have brackets as part of the filename, so of course it throws errors and doesn't give me what I need. How can I fix this? Mind you, the files needing/being copied CAN'T be renamed. I'm not sure how to use "-LiteralPath" here, if that's a solution. :( Here's my code below:$Directory = gci D:\Documents\15075_32\$Destination = "D:\CleanReview"$ReviewSheet = import-csv 'C:\Users\7cm\Desktop\Internal Review - Emails Removed per Attorney Request.csv'$BaseItem = foreach($li in $ReviewSheet){$li.Base}foreach($File in $Directory){ $File.BaseNameforeach($Item in $BaseItem){ if($Item -like $File.BaseName){ $Item Copy-Item $File.FullName $Destination -Force}}}So as you can see, it won't copy items that are declared since the files are going to be variable. If this was a single file, or if I could easily list them as an array I could take care of this... but even -LiteralPath won't work!
Have you seen this problem before in this product?
Please wait...