Skip to content

Proposal: Resolve-Path with -Relative parameter should allow the use of a reference path #8435

@terrabitz

Description

@terrabitz

Summary of the new feature/enhancement

As a PowerShell developer, I want to be able to obtain the path of an item relative to a path that is not my current directory so that I can avoid changing my current location context for a relative directory lookup.

Proposed technical implementation details

Assuming I have a directory like this:

/MyProject
    |-/dir
        |-test_1.txt
        |-test_2.txt
        |-/subdir
            |-test_3.txt

Currently, if I want to do a resolve a path relative to a different directory, I have to use set-location before calling Resolve-Path. For example, if I wanted to get all my .txt file locations relative to dir, I would have to do something like this:

/MyProject> cd dir
/MyProject/dir> Get-ChildItem -Recurse -Include "*.txt" | Resolve-Path -Relative
./subdir/test_3.txt
./test_1.txt
./test_2.txt
/MyProject/dir> cd ..

Ideally, I would like to do something like this:

/MyProject> Get-ChildItem .\dir -Recurse -Include "*.txt" | Resolve-Path -Relative -ReferencePath .\dir
./subdir/test_3.txt
./test_1.txt
./test_2.txt

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-FixedThe issue is fixed.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management moduleWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions