Split-Path: 폴더 경로와 파일명 구분

jy17·2022년 5월 17일
0

PowerShell

목록 보기
2/3

0. 환경

  • OS: Windows 10
  • PSVersion(Powershell Version): 5.1.19041.1645

1. 조사 이유

  • 전체 경로에서 폴더경로와 파일명으로 구분하는 경우가 필요함

2. 문법

1) 폴더경로만 얻기

  • 코드
 Split-Path -Path "C:\Users\Admin\Desktop\UserAccount.txt"
  • e.g.

2) 파일명만 얻기

  • 옵션
    • -Leaf: 경로의 마지막 항목 또는 컨테이너만 반환함
  • 코드
Split-Path -Path "C:\Users\Admin\Desktop\UserAccount.txt" -Leaf
  • e.g.

3) 부모디렉토리 경로 얻기

  • 옵션
    • -Parent: 경로에 지정된 항목 또는 상위 컨텐이너만 반환
  • 코드
Split-Path -Path "C:\Users\Admin\Desktop\UserAccount.txt" -Parent
  • e.g.

0개의 댓글