param($Filename = "log.txt", [switch] $Tabs = $true) $TH = 0; # total hours $Start = ""; function Pause ($Message="Press any key to continue...") { Write-Host -NoNewLine $Message $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Write-Host "" } echo "" > log.csv forEach ($s in (Get-Content $Filename)) { if ($s -match "\d{1,2}:\d\d (A|P)M") { $s = get-date $s if ($Start) { $h = ((Get-Date $s) - $Start).TotalHours; $from = get-date -format "t" $Start $to = get-date -format "t" $s if ($Tabs) { $s = "{0}`t{1}`t{2}`t{3}" } else { $s = "{0} {1} [{2}] = {3}" } $s = $s -f $Start.DayOfWeek.toString().Substring(0,3), (get-date -format "d" $Start), "$from - $to", ("{0:N2}" -f $h) if ($Tabs) { echo $s >> log.csv } else { echo $s } $TH += $h; $Start = ""; } else { $Start = Get-Date $s; } } } #if ($Tabs) { & "C:\Program Files\Microsoft Office\Office12\Excel.exe" log.csv } if ($Tabs) { & "C:\Program Files (x86)\Microsoft Office\Office12\Excel.exe" log.csv } else { Write-Host "Total hours:" ("{0:N2}" -f $TH); pause }