Я пытаюсь добавить PatientOrderNumber к имени файлов в каталоге, если имя файла включает уникальный идентификатор из моего CSV-файла. Я пробовал параметры -like и -contains, но безуспешно.
вот мой код:
$csvPath = "C:\Users\dougadmin28\Desktop\Test\1bs4e.csv"
## Variable to hold path of Files that need to be renamed ##
$filePath = "C:\Users\dougadmin28\Desktop\Node Modify File Name App\pdfs"
$csv = Import-Csv $csvPath #| Select-Object -Property PatientOrderNumber, FileID, DocumentID, LastName, FirstName|Export-Csv 'C:\Users\dougadmin28\Desktop\Node Modify File Name App\documents.csv'
$files = Get-ChildItem $filePath
foreach ($item in $csv){
foreach($file in $files) {
if($file.FullName -contains '*$item.DocumentID*') {
Rename-Item $file.FullName -NewName "$($item.PatientOrderNumber+"_"+($item.FileID)+'_'+($item.DocumentID)+'_'+($item.LastName)+'_'+($item.FirstName)+($file.extension))"
}#End forEach
}#End if
} #End forEach```