powershell - Retrieving the full name of files, filtered by date -
$date = [datetime]("05/19/2014") gci -recurse | select-object fullname,lastwritetime | where-object { $_.lastwritetime.toshortdatestring() -ge $date.toshortdatestring() } | format-table
i'm trying find list of files have been altered on or after 19th of may, 2014. 2 things happening here:
- i'm getting files have been altered far 2009
- the table's columns wide, i'd 100 or characters (i wrong eyeballing this)
how can proper list of files , additionally, how can sort them in such manner readable?
the issue may in how doing comparison. datetime.toshortdatestring method uses whatever short date pattern current culture process using. unfortunately, can't think of example make date in 2009 appear greater date in 2014 in string form. try comparing date-time object directly. compare dates using date
property such:
$date = [datetime]("05/19/2014") gci -recurse | select-object fullname,lastwritetime | where-object { $_.lastwritetime.date -ge $date } | format-table -autosize
note did not need use date
property on $date
variable, when instantiating datetime
object date information, time set 12:00 am. date
property provide value date of original datetime
object time set 12:00 am.
the -autosize
parameter added format-table
take care of second question, automatically resize columns sane width.
Comments
Post a Comment