Skip to content

Add Levels/Count/AncestorCount to Split-Path -Parent parameter set #6659

@powercode

Description

@powercode

I quite often end up in situations where I need to remove a known number of directories from the end of a path.

Today, it requires a looping or piping multiple times to split-path.

$ancestorLevel = 4
$p = "a\b\c\d\e\f"
while($ancestorLevel--){
   $p = split-path $p
}
$p

What is the opinion around having the following?

Split-Path -Parent a\b\c\d\e\f -AncestorLevel 2
a\b\c\d

Split-Path -Parent a\b\c\d\e\f -AncestorLevel 4
a\b

Better naming is left as an exercise for attentive readers with English as their native toungue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions