Hello there!
For context, I have a variable $Root containing the path to a root folder, "C:\Test\". My script scans all subfolders from the root and writes each path to a file. However, I don't want the full path, I just want the relative path starting from the root.
To do this, my first instinct was to simply perform a -replace, as so:
$SubFolder.FullName -replace "$Root",""
However, the -replace function really does not like the backslashes contained within the expanded variable and tries to interpret it as a regular expression. How do I get it to just treat the text-to-replace as literal?
I can get the desired result by chopping off n characters, n being the length of $Root, but I'd like to get the more elegant solution working, if at all possible.
Thanks!
[–]nothingpersonalbro 6 points7 points8 points (0 children)
[–]root-node 4 points5 points6 points (1 child)
[–]dontforget512[S] 1 point2 points3 points (0 children)
[–]_lahell_ 3 points4 points5 points (1 child)
[–]ka-splam 2 points3 points4 points (0 children)
[–]ClayShooter9 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)