PowerShell Logo Small

Split-Path



This is the built-in help made by Microsoft for the command 'Split-Path', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Returns the specified part of a path.

SYNTAX


Split-Path [-IsAbsolute] [-Path] <string[]> [-Credential <PSCredential>] [-LiteralPath <string[]>] [-Resolve] [-UseTransaction] [<CommonParameter
s>]
Split-Path [-Leaf] [-Path] <string[]> [-Credential <PSCredential>] [-LiteralPath <string[]>] [-Resolve] [-UseTransaction] [<CommonParameters>]
Split-Path [-NoQualifier] [-Path] <string[]> [-Credential <PSCredential>] [-LiteralPath <string[]>] [-Resolve] [-UseTransaction] [<CommonParamete
rs>]
Split-Path [-Parent] [-Path] <string[]> [-Credential <PSCredential>] [-LiteralPath <string[]>] [-Resolve] [-UseTransaction] [<CommonParameters>]
Split-Path [[-Qualifier]] [-Path] <string[]> [-Credential <PSCredential>] [-LiteralPath <string[]>] [-Resolve] [-UseTransaction] [<CommonParamete
rs>]



Search powershellhelp.space

DESCRIPTION


The Split-Path cmdlet returns only the specified part of a path, such as the parent directory, a child directory, or a file name. It also can dis
play the items that are referenced by the split path and tell whether the path is relative or absolute.

You can use this cmdlet to display or submit only a selected part of a path.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113404
about_Providers
Test-Path
Convert-Path
Resolve-Path
Join-Path

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>split-path "HKCU:\Software\Microsoft" -qualifier

HKCU:



Description
-----------
This command returns only the qualifier (the drive) of the path.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>split-path "C:\Test\Logs\*.log" -leaf -resolve

Pass1.log
Pass2.log
...



Description
-----------
This command displays the files that are referenced by the split path. Because this path is split to the last item (the "leaf"), only the file na
mes of the paths are displayed.

The Resolve parameter tells Split-Path to display the items that the split path references, instead of displaying the split path.

Like all Split-Path commands, this command returns strings. It does not return FileInfo Objects representing the files.








-------------------------- EXAMPLE 3 --------------------------

C:\PS>split-path "C:\WINDOWS\system32\WindowsPowerShell\V1.0\about_*.txt"

C:\WINDOWS\system32\WindowsPowerShell\V1.0



Description
-----------
This command returns only the parent containers of the path. Because it does not include any parameters to specify the split, Split-Path uses the
split location default, which is Parent.








-------------------------- EXAMPLE 4 --------------------------

C:\PS>split-path ".\My Pictures\*.jpg" -IsAbsolute

False



Description
-----------
This command determines whether the path is relative or absolute. In this case, because the path is relative to the current directory, which is r
epresented by a dot (.), it returns FALSE ($false).








-------------------------- EXAMPLE 5 --------------------------

C:\PS>set-location (split-path $profile)

PS C:\Documents and Settings\juneb\My Documents\WindowsPowerShell>



Description
-----------
This command changes your location to the directory that contains the Windows PowerShell profile.
The command in parentheses uses the Split-Path cmdlet to return only the parent of the path stored in the built-in $Profile variable. (The Parent
parameter is the default split location parameter, so you can omit it from the command.) The parentheses direct Windows PowerShell to execute th
e command first. This is a handy way to navigate to a directory with a long path name.








-------------------------- EXAMPLE 6 --------------------------

C:\PS>'C:\Documents and Settings\User01\My Documents\My Pictures' | split-path

C:\Documents and Settings\User01\My Documents



Description
-----------
This command uses a pipeline operator (|) to send a path to the Split-Path cmdlet. The path is enclosed in quotation marks to indicate that it is
a single token.