String Manipulation



I have variable $path. It contains more than 2 paths like:





I need to trim $path (last *.txt) to : (expectenced)



Does anyone have ane idea how to trim it?


Did you try to search for it? There’s even a builtin cmdlet for Split-Path !!!

Yes I treid. I was focused to manipulation text with split, splitend and indexof. i did’n knwo split-path cmdlet

or you could use both split and trim like:


I’m afraid the .trim() method does not work like you think it does. Try the following snippet. It might help you to understand

'trim specified charachters'.trim('srthcae')

Use the Split-Path command. Of course since your original variable is an array of paths you will need to iterate through that array and run the Split-Path on each element of the array.