in powershell the name of folders in a path can be specified

You can use .Split("\") to the path folder

$pathfolder = "C:\folder1\folder2\folder3\folder4"
$pathfolder.Split("\")

cls
$pathfolder = "C:\folder1\folder2\folder3\folder4"
$A = $pathfolder.Split("\")
$Count = $pathfolder.Split("\").Count

For ($i=1; $i -le $Count+1; $i++) {
    echo $A[$i]
}

$pathfolder = "C:\folder1\folder2\folder3\folder4"
$A = $pathfolder.Split("\")

echo "The folder number 2 with name : " $A[2]
echo "The folder number 3 with name : " $A[3]

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top