Reputation: 823
I have a csv file looks like this:
foo.html,9,0
bar.html,0,3
otherfile.html,9,1
Every row in this csv file, contains a filename. I need to replace the filename with the fullpath of this filename.
for example, foo.html
should be replace with c:\somefolder\sub\sub\foo.html
.
c:\somefolder
.How to do that with Powershell
?
Upvotes: 0
Views: 1708
Reputation: 3046
Following your comment that you know how to get the names from the csv and know that the files are in the the folder C:\somefolder
you can try to loop this:
$allItems = Get-ChildItem -Recurse C:\somefolder
$fullname = @()
foreach ($item in $itemsFromCsv)
{
$fullname += $a | Where-Object {$_.Name -eq $file} | Select-Object -ExpandProperty Fullname
}
This searches you the Fullname (path + Name) and saves it in the array $fullname
.
You can then add the array to your csv and export it.
Upvotes: 3