PowerShell: Bölünmüş Yol Örnekleri
Cmdlet Split-Path birimleri, klasörleri ve dosya yolu adlarını bölmek için yararlı olabilir. Bu blog yazılarında size geliştirebileceğiniz bazı örnekler vereceğim. Split-Path'in gücü hakkında daha fazla bilgi edinmek için kod örneklerini okurken eğlenin.
Kod Örnekleri
Lütfen aşağıdaki kod örneğine ve açıklamalarına bakın.
# Split Paths
# Show file path
Split-Path $home\documents\test.txt -Parent
# Show last element
Split-Path $home\documents\text.txt -Leaf
Split-Path $home\documents -Leaf
# Show Drive Letter
Split-Path $home\documents\text.txt -Qualifier
# Path without Drive Letter
Split-Path $home\documents\text.txt -NoQualifier
# Resolve Name (Show full path)
Split-Path $home\documents -Resolve
# Show Sub-Folder (dir3)
Split-Path (Split-Path c:\dir1\dir2\dir3\file.txt -Parent) -Leaf
# Show Sub-Folder (dir2)
Split-Path c:\dir1\dir2\dir3\file.txt -Parent |
# Show Sub-Folder (dir2)
Split-Path c:\dir1\dir2\dir3\file.txt -Parent | Split-Path -Leaf
# Or ...
('c:\dir1\dir2\dir3\file.txt' -split '\\')[2]
# Displays all word documents file names
Set-Location C:\
Split-Path -Path .\temp\*.docx -Resolve -Leaf
# Is this an absolute path ?
Split-Path $home\documents\text.txt -IsAbsolute
Split-Path .\Windows -IsAbsolute
# Combination ?
(Split-Path C:\Windows\system32) + '\'
+ (Split-Path $home\documents\test.txt -Leaf)
Umarım bu makale faydalı olmuştur!