I run the command (Get-Location), and it returns the current location of a file.
Example: c:\folder1\folder2\folder3\XXX\folder4\folder5
Firstly, from the above, I want to get the value of XXX and let it equal to a variable. How can I do this?
Secondly, I want to get the value of c:\folder1\folder2\folder3\XXX\folder4\ and let it equal to a variable. How can I do this?
I have used the placeholders folder1, folder2, etc. for illustration. These are dynamic.
To get the path into a variable, you can do something like this:
Then, if you want to set the value of the ‘XXX’ part of your path to a variable, you can use the split() function: