Skip to content

Commit

Permalink
v2.1.2
Browse files Browse the repository at this point in the history
* Addressed issue #8 - If no files are found, nothing is logged and the
script terminates. This cuts down on log clutter, as well as frees up
the CPU and process for those running the script very frequently as a
scheduled task.
* If $appendLog = $True, the script version header will only be printed
to the log if the log is empty in order to cut down on log clutter.
* "New session" header is only printed to the log if files are found and
added to the queue to cut down on log clutter.
  • Loading branch information
BrianDMG committed Apr 13, 2017
1 parent 99a25ed commit bf6cae6
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions conv2mp4-ps.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<#======================================================================================================================
conv2mp4-ps - https://github.com/BrianDMG/conv2mp4-ps v2.1.1 RELEASE
conv2mp4-ps v2.1.2 RELEASE - https://github.com/BrianDMG/conv2mp4-ps
This Powershell script will recursively search through a user-defined file path and convert all videos of user-specified
filetypes to MP4 with H264 video and AAC audio using ffmpeg. If a conversion failure is detected, the script re-encodes
Expand Down Expand Up @@ -44,25 +44,11 @@ $appendLog = $False
Static variables
----------------------------------------------------------------------------------#>
#Script version information
$version = "v2.1.1 RELEASE"
$version = "v2.1.2 RELEASE"
# Time and format used for timestamps in the log
$time = {Get-Date -format "MM/dd/yy HH:mm:ss"}
#Join-Path for log file
$log = Join-Path "$logPath" "$logName"
#Should the log append or clear
If ($appendLog -eq $False)
{
# Clear log contents
Clear-Content $log
}
Else
{
Write-Output "`n`n------------------------------------------------------------------------------------" | Tee -filepath $log -append
Write-Output ">>>>> NEW SESSION (started $($time.Invoke()))" | Tee -filepath $log -append
}
# Print version information to top of log
Write-Output "`nconv2mp4-ps $version - https://github.com/BrianDMG/conv2mp4-ps" | Tee -filepath $log -append
Write-Output "------------------------------------------------------------------------------------" | Tee -filepath $log -append
# Print initial wait notice to console
Write-Host "`nBuilding file list, please wait. This may take a while, especially for large libraries.`n"
# Get current time to store as start time for script
Expand Down Expand Up @@ -134,20 +120,50 @@ Functions
Param ([string]$logString)
Write-Output $logString | Tee -filepath $log -append
}
# Prints the current script version header
Function PrintVersion
{
Log "conv2mp4-ps $version - https://github.com/BrianDMG/conv2mp4-ps"
Log "------------------------------------------------------------------------------------"
}
# Append log conditions
Function AppendLog
{
#Check whether log file is empty
$logEmpty = Get-Content $log
#Should the log append or clear
If ($appendLog -eq $False)
{
Clear-Content $log
PrintVersion
}
Elseif ($appendLog -eq $True -AND $logEmpty -eq $Null)
{
PrintVersion
}
Else
{
Log "`n------------------------------------------------------------------------------------"
Log ">>>>> New Session (started $($time.Invoke()))"
}
}
# List files in the queue in the log
Function ListFiles
{
If ($fileCount -eq 1)
{
AppendLog
Log ("`nThere is $fileCount file in the queue:`n")
}
Elseif ($fileCount -gt 1)
{
AppendLog
Log ("`nThere are $fileCount files in the queue:`n")
}
Else
{
Log ("`nThere are no files to be converted in $mediaPath. Congrats!`n")
Write-Host ("`nThere are no files to be converted in $mediaPath. Congrats!`n")
Exit
}

$num = 0
Expand Down

0 comments on commit bf6cae6

Please sign in to comment.