Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
8c0ea4580f | |||
663d8651e4 | |||
dda380f7dd | |||
a7a02c7ec5 | |||
c40c3e245c | |||
777e176e81 | |||
a1b2aba5a6 | |||
e4130baddb | |||
112b097ed8 | |||
d3fc9c98d5 | |||
237545482b | |||
1588f08c10 |
@ -1,3 +1,9 @@
|
||||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
|
||||
[![Release](https://img.shields.io/badge/Release-v1.2-brightgreen)](https://code.obermui.de/6543/LogWert/releases)
|
||||
[![PGP Sig](https://img.shields.io/keybase/pgp/6543)](https://mh.obermui.de/publickey.gpg)
|
||||
|
||||
# LogWert
|
||||
|
||||
Fasst die RoboCopy Log's zusammen
|
||||
Summarizes the RoboCopy Log's
|
||||
|
||||
exec: `./logwert.ps1 [path-log1] [path-log2] [path-log3] ... `
|
||||
|
81
logwert.ps1
Normal file → Executable file
81
logwert.ps1
Normal file → Executable file
@ -1,17 +1,16 @@
|
||||
#
|
||||
#!/usr/bin/pwsh
|
||||
|
||||
|
||||
##############################################################
|
||||
## ##
|
||||
## logwert.ps1 version. 1.2 ##
|
||||
## ##
|
||||
## Dies ist ein Hilfsscript fuer _shares_spiegeln.bat ##
|
||||
## und der Nachfolger des CMD-Scriptes "logwert.cmd", ##
|
||||
## Es wertet die Robologfile aus und fast diese zusammen. ##
|
||||
## This is a smal help script ##
|
||||
## It evaluates robocopy logs and summarizes them ##
|
||||
## ##
|
||||
## @parameter: [Pfad-Log1] [Pfad-Log2] [Pfad-Log3] ... ##
|
||||
## @parameter: [path-log1] [path-log2] [path-log3] ... ##
|
||||
## ##
|
||||
## @author: Martin.Huber@stbaro.bayern.de ##
|
||||
## @author: 6543@obermui.de ##
|
||||
## ##
|
||||
##############################################################
|
||||
|
||||
@ -35,16 +34,16 @@
|
||||
|
||||
################################### Functionen ##########################################################
|
||||
|
||||
function Log_Start ([String]$sLogPfad){
|
||||
If(Test-Path $sLogPfad) { #Testen Ob Datei Existiert
|
||||
function Log_Start ([String]$sLogpath){
|
||||
If(Test-Path $sLogpath) { #test if file exists
|
||||
$tmp = ""
|
||||
$tmp = Get-Content $sLogPfad #Inhalt in Array
|
||||
$tmp | ForEach-Object { Log_Main $_ } #Jede Zeile des 1D Arrays einzeln Bearbeiten
|
||||
$tmp = Get-Content $sLogpath #copy file into list
|
||||
$tmp | ForEach-Object { Log_Main $_ } #process each line
|
||||
}
|
||||
} #Starte Verarbeitung
|
||||
} # start processing
|
||||
|
||||
function Log_Main ([String]$sLine){
|
||||
#Trenn Zeichen Setzen
|
||||
# separate Set character
|
||||
$sLine = $sLine.replace("`"", "#")
|
||||
$sLine = $sLine.replace(",", "#")
|
||||
$sLine = $sLine.replace("Insgesamt:", "")
|
||||
@ -52,32 +51,32 @@ $sLine = $sLine.replace("Insgesamt:", "")
|
||||
if($sLine -match "[0-z]") {
|
||||
|
||||
|
||||
###Anomalien ausschließen
|
||||
### rule out anomalies
|
||||
|
||||
while(" ".Equals($sLine.Substring(0,1))) {$sLine = $sLine.Substring(1, $sLine.Length - 1)}
|
||||
#Wenn String Mit Lehrzeichen beginnt entfernen
|
||||
#Remove when String Begins with Lehrzeichen
|
||||
while("#".Equals($sLine.Substring(0,1))) {$sLine = $sLine.Substring(1, $sLine.Length - 1)}
|
||||
#Wenn String Mit Trenzeichen beginnt entfernen
|
||||
#If string begins with delimiter remove
|
||||
while(" ".Equals($sLine.Substring($sLine.Length - 1,1))) {$sLine = $sLine.Substring(0, $sLine.Length - 1)}
|
||||
#Wenn String Mit Lehrzeichen endet entfernen
|
||||
#If String Ends with Lehrzeichen Remove String
|
||||
while("#".Equals($sLine.Substring($sLine.Length - 1,1))) {$sLine = $sLine.Substring(0, $sLine.Length - 1)}
|
||||
#Wenn String Mit Trenzeichen endet entfernen
|
||||
#Remove if string ends with delimiters
|
||||
while($sLine.IndexOf("##") -gt -1 ) {$sLine = $sLine.Replace("##", "#")}
|
||||
#Mehrere hintereinander folgende Trenzeichen entfernen
|
||||
#Remove several following delimiters in a row
|
||||
while($sLine.IndexOf(" ") -gt -1 ) {$sLine = $sLine.Replace(" ", " ")}
|
||||
#Mehrere hintereinander folgende Lehrzeichen entfernen
|
||||
#Remove several following characters in a row
|
||||
$sLine.Split("#") | ForEach-Object { WichCase $_ }
|
||||
}
|
||||
} #Zeilenweise auswertung
|
||||
} #Line by line evaluation
|
||||
|
||||
function WichCase ([String]$sToken) {
|
||||
|
||||
if($sToken -match "[0-z]") {
|
||||
|
||||
while(" ".Equals($sToken.Substring(0,1))) {$sToken = $sToken.Substring(1, $sToken.Length - 1)}
|
||||
#Lehrzeichen vor werten entfernen
|
||||
#remove blank before rating
|
||||
while(" ".Equals($sToken.Substring($sToken.Length - 1,1))) {$sToken = $sToken.Substring(0, $sToken.Length - 1)}
|
||||
#Lehrzeichen nach werten entfernen
|
||||
#remove blank avter rating
|
||||
|
||||
$aToken = $sToken.Split(" ")
|
||||
|
||||
@ -98,14 +97,14 @@ if($sToken -match "[0-z]") {
|
||||
[Double]$Global:zLog_Copy_Size += (Calc_Byte_Sice $aToken[3] $aToken[4] b)
|
||||
[Double]$Global:zLog_Copy_real_Size += (Calc_Byte_Sice $aToken[0] $aToken[1] b)
|
||||
}
|
||||
} #Übergabe der Zeile; Auswertung; Speicherung in Globale Variablen
|
||||
} #Transfer of the line; evaluation; storage in global variables
|
||||
|
||||
function Calc_Byte_Sice ([Double]$Wert, [String]$EinheitEingabe, [String]$EinheitAusgabe ) {
|
||||
|
||||
#Calc_Byte_Sice: [Wert] [Einheit-Ausgabe] [Einheit-Eingabe]
|
||||
# Wenn bei Einheit etwas anderes als KB,MB,GB,TB eingebeben Wird, Wird mit Bytes gerechnet
|
||||
#Calc_Byte_Sice: [value] [unit outpute] [unit input]
|
||||
# If you enter something other than KB,MB,GB,TB for unit, it is calculated with bytes.
|
||||
|
||||
#fertieren der unterschiedlichen Groeßenangaben (umrechnungseinheit= 1024)
|
||||
#fertieren the different size specifications (conversion unit= 1024)
|
||||
# b (=Bytes), k (=Kilobytes), m (=Megabytes), g (=Gigabytes) und t (=Terabytes)
|
||||
|
||||
If("".Equals("$Wert") -and "0".Equals("$Wert")) {return 0} else {
|
||||
@ -120,7 +119,7 @@ function Calc_Byte_Sice ([Double]$Wert, [String]$EinheitEingabe, [String]$Einhei
|
||||
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("G","g")
|
||||
$EinheitAusgabe = ($EinheitAusgabe.substring(0,1)).replace("T","t")
|
||||
|
||||
# Abfangen von Größenangaben die es nicht giebt/die nicht behandelt werden
|
||||
# Catching size information that does not exist/that are not handled
|
||||
If ( -not ("b".Equals("$EinheitAusgabe") -or "k".Equals("$EinheitAusgabe") -or "m".Equals("$EinheitAusgabe") -or "g".Equals("$EinheitAusgabe") -or "t".Equals("$EinheitAusgabe"))) {$EinheitAusgabe = "else"}
|
||||
If ( -not ("b".Equals("$EinheitEingabe") -or "k".Equals("$EinheitEingabe") -or "m".Equals("$EinheitEingabe") -or "g".Equals("$EinheitEingabe") -or "t".Equals("$EinheitEingabe"))) {$EinheitEingabe = "else"}
|
||||
|
||||
@ -155,18 +154,26 @@ function Calc_Byte_Sice ([Double]$Wert, [String]$EinheitEingabe, [String]$Einhei
|
||||
}
|
||||
return $Wert
|
||||
}
|
||||
} #[Wert] [Einheit-Ausgabe] [Einheit-Eingabe]
|
||||
} #[value] [unit outpute] [unit input]
|
||||
|
||||
##########################################################################################################
|
||||
|
||||
#for each param do start(param)
|
||||
$args | ForEach-Object { Log_Start $_ }
|
||||
If ($args[0] -eq "--version") {
|
||||
echo "Version: 1.2"
|
||||
} ElseIf ($args[0] -eq "--help") {
|
||||
echo "./logwert.ps1 [log1] [log2] ..."
|
||||
} Else {
|
||||
|
||||
[String]$sLog_Copy_errors = "$Global:zLog_Copy_errors"
|
||||
[String]$sLog_Copy_Size = [math]::round((Calc_Byte_Sice $Global:zLog_Copy_Size b $Global:Log_Copy_Size_Einheit), 2)
|
||||
[String]$sLog_Copy_real_Size = [math]::round((Calc_Byte_Sice $Global:zLog_Copy_real_Size b $Global:Log_Copy_Size_Einheit), 2)
|
||||
[String]$sLog_Copy_item = "$Global:zLog_Copy_item"
|
||||
[String]$sLog_Copy_real_item = "$Global:zLog_Copy_real_item"
|
||||
[String]$sLog_Copy_Size_Einheit = "$Global:Log_Copy_Size_Einheit"
|
||||
#for each param do start(param)
|
||||
$args | ForEach-Object { Log_Start $_ }
|
||||
|
||||
echo "Insgesamt: $sLog_Copy_real_item von $sLog_Copy_item Dateien kopiert, $sLog_Copy_errors Fehler, $sLog_Copy_real_Size $sLog_Copy_Size_Einheit von $sLog_Copy_Size $sLog_Copy_Size_Einheit kopiert"
|
||||
[String]$sLog_Copy_errors = "$Global:zLog_Copy_errors"
|
||||
[String]$sLog_Copy_Size = [math]::round((Calc_Byte_Sice $Global:zLog_Copy_Size b $Global:Log_Copy_Size_Einheit), 2)
|
||||
[String]$sLog_Copy_real_Size = [math]::round((Calc_Byte_Sice $Global:zLog_Copy_real_Size b $Global:Log_Copy_Size_Einheit), 2)
|
||||
[String]$sLog_Copy_item = "$Global:zLog_Copy_item"
|
||||
[String]$sLog_Copy_real_item = "$Global:zLog_Copy_real_item"
|
||||
[String]$sLog_Copy_Size_Einheit = "$Global:Log_Copy_Size_Einheit"
|
||||
|
||||
echo "Summary: $sLog_Copy_real_item of $sLog_Copy_item files copied, $sLog_Copy_errors errors, $sLog_Copy_real_Size $sLog_Copy_Size_Einheit of $sLog_Copy_Size $sLog_Copy_Size_Einheit copied"
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user