본문 바로가기

Windows 10/PowerShell

PowerShell : Get-ChildItem (ls), 응용

반응형
  • ls

    Get-ChildItem  
  • ls (Alias)

    ls
    ls C:\
  • 필터

    ls -filter *.jpg
  • 다중필터 (Where 적용)

    ls | Where {$_.extension -in ".mp4", ".avi", ".mkv"}
  • 폴더만 표시

     ls -directory
     ls -dir
     ls -ad
  • 파일만 표시

    ls -file
    ls -af
  • 숨긴파일만 표시

      ls -hidden
  • 파일 전체경로 표시

      ls | select fullname
      ls | % {$_.fullname}
  • 속성으로 찾기

    ls -attribute r
    ls -attr r
    ls -attr d+r
    ls -attr d+!r
    ls -attr !d
  • mode로 찾기

    ls | where {$_.mode -in "d-r---"}
  • 파일 개수 확인 (Measure-Object)

    ls | Measure-Object

 

 

Get-ChildItem (Microsoft.PowerShell.Management)

The Get-ChildItem cmdlet gets the items in one or more specified locations. If the item is a container, it gets the items inside the container, known as child items. You can use the Recurse parameter to get items in all child containers and use the Depth p

docs.microsoft.com

 

반응형