I have approximately 100,000 photographs taken each minute of every day for several months.
I would like to be able to delete the ones taken after say 8PM and before 6AM with either a batch or powershell script.
Is this possible?
I have approximately 100,000 photographs taken each minute of every day for several months.
I would like to be able to delete the ones taken after say 8PM and before 6AM with either a batch or powershell script.
Is this possible?
The file property CreationTime is what i am assuming you are looking for.
PS M:\Scripts> (Get-Item .\Clean-UninstallKeysLog.vbs).CreationTime | fl
Date : 6/24/2014 12:00:00 AM
Day : 24
DayOfWeek : Tuesday
DayOfYear : 175
Hour : 15
Kind : Local
Millisecond : 928
Minute : 18
Month : 6
Second : 47
Ticks : 635392199279286738
TimeOfDay : 15:18:47.9286738
Year : 2014
DateTime : Tuesday, June 24, 2014 3:18:47 PM
Using that you can extract the hour property and edit your preexisting script looking for hours < 6 and > 20. In the example above i get 15 for the hour
((Get-Item .\Clean-UninstallKeysLog.vbs).CreationTime).Hour
15
I went into my downloads folder and did this in PowerShell:
> $all_files = Get-ChildItem
> $all_files.Count
471
> $some_files = (Get-ChildItem) | Where-Object {$_.CreationTime.TimeOfDay.Hours -gt 18 -and $_.CreationTime.TimeOfDay.Hours -lt 20}
> $some_files.Count
21
You could also do this to see the available properties under CreationTime
:
PS D:\Downloads> (gci .\somefile.zip).CreationTime | Get-Member -MemberType Property
TypeName: System.DateTime
Name MemberType Definition
---- ---------- ----------
Date Property datetime Date {get;}
Day Property int Day {get;}
DayOfWeek Property System.DayOfWeek DayOfWeek {get;}
DayOfYear Property int DayOfYear {get;}
Hour Property int Hour {get;}
Kind Property System.DateTimeKind Kind {get;}
Millisecond Property int Millisecond {get;}
Minute Property int Minute {get;}
Month Property int Month {get;}
Second Property int Second {get;}
Ticks Property long Ticks {get;}
TimeOfDay Property timespan TimeOfDay {get;}
Year Property int Year {get;}