Added year-parameter
This commit is contained in:
@@ -5,10 +5,11 @@
|
||||
# v1.2 - Some bugfixes for running as scheduled task, month-handling, etc.
|
||||
# v1.1 - A bit more dynamic, updated ffmpeg to newest available version, changed codec to x265, added parameter handling
|
||||
# v1.0 - Initial concept
|
||||
param ($Camera,$Style='Daily',[string]$Month)
|
||||
param ($Camera,$Style='Daily',[string]$Month,$Year)
|
||||
|
||||
Set-Location $PSScriptRoot
|
||||
|
||||
|
||||
if (!$Camera) { $Camera = Read-Host "Enter camera you want to process" }
|
||||
|
||||
switch ($Style) {
|
||||
@@ -27,6 +28,11 @@ $CompletedTimelapseDir = "\\megabyte.home.zyrex.org\Mediavault\Privat\Timelapses
|
||||
$MonthProcess = (Get-Date).AddMonths(-1)
|
||||
$MonthProcess = $MonthProcess|Get-Date -Format MM
|
||||
|
||||
# Set this year if not passed
|
||||
if (!$Year) {
|
||||
$Year = (Get-Date).Year
|
||||
}
|
||||
|
||||
# Use passed parameter if it exists
|
||||
if ($Month) {
|
||||
$MonthProcess = $Month
|
||||
@@ -36,11 +42,11 @@ if ($Month) {
|
||||
$photos = Get-ChildItem $TimelapsePhotoSrc
|
||||
|
||||
if ($style -eq "Monthly") {
|
||||
$Copyphotos = $photos | Where-Object {$_.name -Like "$($Camera)_????$($MonthProcess)??_12-00-??.jpg"}
|
||||
$Copyphotos = $photos | Where-Object {$_.name -Like "$($Camera)_$($Year)$($MonthProcess)??_12-00-??.jpg"}
|
||||
}
|
||||
elseif ($Style -eq "Daily") {
|
||||
$photos = $photos|Where-Object {$_.length -gt 120000} # Maybe do a check on the size, it will require tuning
|
||||
$Copyphotos = $photos | Where-Object {$_.name -Like "$($Camera)_????$($MonthProcess)*"}
|
||||
$Copyphotos = $photos | Where-Object {$_.name -Like "$($Camera)_$($Year)$($MonthProcess)*"}
|
||||
}
|
||||
#elseif ($Style -eq "Yearly") {
|
||||
# # Takes all previous monthlies and combines them to a yearly timelapse
|
||||
@@ -54,7 +60,7 @@ $regex = '(?<filedate>\d{4}(?:\.|-|_)?\d{2}(?:\.|-|_)?\d{2})[^0-9]'
|
||||
If($Copyphotos[1] -match $regex) {
|
||||
$date = $Matches['filedate'] -replace '(\.|-|_)',''
|
||||
$date = [datetime]::ParseExact($date,'yyyyMMdd',[cultureinfo]::InvariantCulture)
|
||||
$Year = Get-date $date -Format yyyy
|
||||
# $Year = Get-date $date -Format yyyy
|
||||
}
|
||||
|
||||
foreach ($lapse in $Copyphotos) {
|
||||
|
||||
Reference in New Issue
Block a user