Skip to content

Get SamplerAbsolutePath

gaelcolas edited this page Jul 18, 2024 · 1 revision

Get-SamplerAbsolutePath

SYNOPSIS

Gets the absolute value of a path, that can be relative to another folder or the current Working Directory $PWD or Drive.

SYNTAX

Get-SamplerAbsolutePath [[-Path] <String>] [[-RelativeTo] <String>] 
 [<CommonParameters>]

DESCRIPTION

This function will resolve the Absolute value of a path, whether it's potentially relative to another path, relative to the current working directory, or it's provided with an absolute Path.

The Path does not need to exist, but the command will use the right [System.Io.Path]::DirectorySeparatorChar for the OS, and adjust the .. and . of a path by removing parts of a path when needed.

EXAMPLES

EXAMPLE 1

Get-SamplerAbsolutePath -Path '/src' -RelativeTo 'C:\Windows'
# C:\src

EXAMPLE 2

Get-SamplerAbsolutePath -Path 'MySubFolder' -RelativeTo '/src'
# C:\src\MySubFolder

PARAMETERS

-Path

Relative or Absolute Path to resolve, can also be $null/Empty and will return the RelativeTo absolute path. It can be Absolute but relative to the current drive: i.e. /Windows would resolve to C:\Windows on most Windows systems.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RelativeTo

Path to prepend to $Path if $Path is not Absolute. If $RelativeTo is not absolute either, it will first be resolved using [System.Io.Path]::GetFullPath($RelativeTo) before being pre-pended to $Path.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.String

NOTES

When the root drive is omitted on Windows, the path is not considered absolute. Split-Path -IsAbsolute -Path '/src/

$false

RELATED LINKS

Clone this wiki locally