Basically I have a path
"root/main/EVILFOLDER/first/second/third/etc"
And I want to remove EVILFOLDER/
specifically the 3rd segment of the path. The thing is EVILFOLDER could be anything so I can't just hardcode it as such and the path length and number of "/" could be any varying length.
I have this, and it works, but elegant it is not.
$path = "root/main/EVILFOLDER/first/second/third/etc"
$basePath = "{0}/{1}/" -f $path.Split('/')
$subFolder = "{3}/" -f $shortPath.Split('/')
$subFolderIndex = $shortPath.IndexOf($subFolder)
$newPath = $basePath + $shortPath.Substring($subFolderIndex)
Ultimately I was hoping I could write it as somethingl ike "{0}/{1}/{3}... " to get the rest of the path listing. Ideas?