How to do it...

Navigate to the location where you created files for use with this book.

  1. List out the contents of this directory to see what content you have. (If you are like me, you would have even forgotten where you created this directory, and what content you put in.)
PS> Set-Location ~/random
PS> Get-ChildItem -Path .

Notice the names of the properties you got.

  1. Now, pick only those files that are larger than 0 bytes.
PS> Get-ChildItem -Path . | Where-Object -Property Length -GT -Value 0
  1. Pick out all the JPG files from the lot. To do this, add another condition to the existing condition. Although, this time, use the FilterScript parameter instead of Property.
PS> Get-ChildItem -Path . | Where-Object -FilterScript {$_.Length -GT 0 -and $_.Extension -EQ '.jpg'}
  1. Add a condition to get only those files whose names start with 'c'.
PS> Get-ChildItem -Path . | Where-Object -FilterScript {$_.Length -GT 0 -and $_.Extension -EQ '.jpg' -and $_.Name -CMatch '^c'}
  1. Now, choose those files which were created before the 30th minute of any hour.
PS> Get-ChildItem -Path . | Where-Object -FilterScript {$_.Length -GT 0 -and $_.Extension -EQ '.jpg' -and $_.Name -CMatch '^c' -and $_.LastWriteTime.Minute -LT 30}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.42.94