I have to copy the files of diferent directories in their directory changing their name. I have some problems with the command split.
The variable $nom contains all the files in a directory: example: a.out b.out c.out Then I want to cut the first word. "a" -> a.out
But when I try to do this it stores also a " ".
Because when I execute write-host $nomArxiu it prints: a _directory1.out and my final resultat has to be a_directory1.out
Can anyone tell me what I am doing wrong. Thank you
The result of
-splitis an array.You only want one field not both (which you get when you use
$test0.Try
$test0[0].Or use a more appropriate function for this:
or (since
$_is anIO.FileInfoobject just use itsBaseNameproperty):