For patterns like these you could also work with Regular Expressions.
Underneath i use the .NET class of REGEX and not the build in REGEX function (-match). The script would look like :
$string = "
Path,
[Evidence 1],
[Evidence 1, Folder A,],
[Evidence 1, Folder A, AK-472.png ],
[Evidence 1, Folder A, data.lua ],
[Evidence 1, Folder A, glock_19.jpg],
[Evidence 1, Folder A, Nuix 7.2.lnk],
[Evidence 1, Folder A, Nuix Web review.url],
"
# Display string for debugging
$string
$m = ([regex]::Matches($string,'((?<=, ).*(?=]))') | % { $_.groups[0].value } )
foreach($x in $m){
$folder = [regex]::Matches($x,'(.*(?=,))') | % { $_.groups[0].value }
$item = [regex]::Matches($x,'((?<=, ).*)') | % { $_.groups[0].value }
"c:\"+$folder.Trim(' ')+"\"+$item
}
This would give us the following output:
c:\Folder A\
c:\Folder A\AK-472.png
c:\Folder A\data.lua
c:\Folder A\glock_19.jpg
c:\Folder A\Nuix 7.2.lnk
c:\Folder A\Nuix Web review.url
What i do is i take only the content i need and put it into $m
So at that point, $M contains: "Folder A, AK-472.png "
What i then do is i loop through all the items and catch the folder and item with an individual regex (based upon the first one).
So
$folder = [regex]::Matches($x,'(.*(?=,))') | % { $_.groups[0].value }
would give us "Folder A"
and
$item = [regex]::Matches($x,'((?<=, ).*)') | % { $_.groups[0].value }
would give us "AK-472.png"
All there is left to do now, is to create out own new path:
"c:\"+$folder.Trim(' ')+"\"+$item
I trim the space otherwise it would look like:
c:\Folder A \AK-472.png