Script noob, need a little help with text manipulation. I need to take apart a url, in the format below:
\serversharefolderafolderb…filename
Then re-assemble it dropping the \servershare and the filename (but do want to save the filename. The url's are all variable length.
I was playing around with this:
GC c:workinfile.txt |
%{
$pieces = $_.Split("")
$numpieces = $pieces.count
# $filename = $pieces[($pieces.length)]
$pieces
$numpieces
# $filename
$pieces.RemoveRange(0,3)
$pieces
}
But the RemoveRange method is not working and also not getting the Filename pull to work, have tried a few variations, this was where I left off.
Thanks for the help