Schönheitsfehler entfernt, Prüfung nach Datentyp bei Versionierung
This commit is contained in:
parent
9ce725ca2c
commit
a32443cf86
@ -23,7 +23,7 @@ Function MoveOrCopy-Item-withLogging {
|
|||||||
Write-Logfile
|
Write-Logfile
|
||||||
|
|
||||||
.VERSION
|
.VERSION
|
||||||
1.2.1.1 / 17.12.2016
|
1.2.1.2 / 23.02.2024
|
||||||
|
|
||||||
.PARAMETER SourceFile
|
.PARAMETER SourceFile
|
||||||
Give the full Path and Filename to one File.
|
Give the full Path and Filename to one File.
|
||||||
@ -84,9 +84,7 @@ Function MoveOrCopy-Item-withLogging {
|
|||||||
#Checking if "Write-LogFile" Module was loaded
|
#Checking if "Write-LogFile" Module was loaded
|
||||||
IF (Get-Module -Name "Write-LogFile") {
|
IF (Get-Module -Name "Write-LogFile") {
|
||||||
|
|
||||||
$FileTest = Test-Path "$SourceFile" -PathType Leaf
|
IF ((Test-Path $SourceFile -PathType Leaf) -eq $True) {
|
||||||
|
|
||||||
IF ($Filetest -eq 'True') {
|
|
||||||
|
|
||||||
Write-Logfile -LogLine ""
|
Write-Logfile -LogLine ""
|
||||||
$SourcePath = ([System.IO.Path]::GetDirectoryName($SourceFile).ToString())
|
$SourcePath = ([System.IO.Path]::GetDirectoryName($SourceFile).ToString())
|
||||||
@ -132,13 +130,16 @@ Function MoveOrCopy-Item-withLogging {
|
|||||||
# Does file already exist in the target directory?
|
# Does file already exist in the target directory?
|
||||||
$FileTest = Test-Path "$DestinationPath\$FileName" -PathType Leaf
|
$FileTest = Test-Path "$DestinationPath\$FileName" -PathType Leaf
|
||||||
|
|
||||||
IF ($Filetest -eq 'True') {
|
IF ($Filetest -eq $True) {
|
||||||
|
|
||||||
Write-Logfile -LogLine "The File ($Filename) already exists in the target directory, starting Version Check."
|
Write-Logfile -LogLine "The File ($Filename) already exists in the target directory, starting Version Check."
|
||||||
|
|
||||||
[String]$FileNameSplit = ($Filename_noExt -split "$VersionSeperator")
|
[String]$FileNameSplit = ($Filename_noExt -split $VersionSeperator)
|
||||||
[Int]$FileVersion = $NULL
|
[Int]$FileVersion = 0
|
||||||
[Int]$FileVersion = $FileNameSplit[1]
|
|
||||||
|
IF ($FileNameSplit[1] -is [Int]) {
|
||||||
|
[Int]$FileVersion = $FileNameSplit[1]
|
||||||
|
} #end if
|
||||||
|
|
||||||
# Has the new file already a Version tag?
|
# Has the new file already a Version tag?
|
||||||
IF ($FileVersion -eq 0) {
|
IF ($FileVersion -eq 0) {
|
||||||
@ -166,12 +167,12 @@ Function MoveOrCopy-Item-withLogging {
|
|||||||
# code block for the copy or move process
|
# code block for the copy or move process
|
||||||
Try {
|
Try {
|
||||||
|
|
||||||
Set-Variable -Name FileHash_befor -Value (Get-FileHash -Path "$SourceFile" -Algorithm SHA512 | select Hash | Foreach-Object {$_ -replace "@{Hash=", ""} | Foreach-Object {$_ -replace "}", ""})
|
Set-Variable -Name FileHash_befor -Value (Get-FileHash -Path "$SourceFile" -Algorithm SHA512 | Select-Object Hash | Foreach-Object {$_ -replace "@{Hash=", ""} | Foreach-Object {$_ -replace "}", ""})
|
||||||
Set-Variable -Name FileTemp -Value (Copy-Item -Path "$SourceFile" -Destination "$DestinationPath\$Timestamp3`_$FileName" -PassThru -Force)
|
Set-Variable -Name FileTemp -Value (Copy-Item -Path "$SourceFile" -Destination "$DestinationPath\$Timestamp3`_$FileName" -PassThru -Force)
|
||||||
Write-Logfile -LogLine "The $Action command has been completed."
|
Write-Logfile -LogLine "The $Action command has been completed."
|
||||||
Set-Variable -Name FileFinal -Value (Rename-Item -Path "$FileTemp" -NewName "$FileName_noExt$VersionSeperator$FileVersion$FileExtension" -PassThru -Force )
|
Set-Variable -Name FileFinal -Value (Rename-Item -Path "$FileTemp" -NewName "$FileName_noExt$VersionSeperator$FileVersion$FileExtension" -PassThru -Force )
|
||||||
Write-Logfile -LogLine "File was renamed to: $FileName_noExt$VersionSeperator$FileVersion$FileExtension, and is now transferd to: $DestinationPath."
|
Write-Logfile -LogLine "File was renamed to: $FileName_noExt$VersionSeperator$FileVersion$FileExtension, and is now transferd to: $DestinationPath."
|
||||||
Set-Variable -Name FileHash_after -Value (Get-FileHash -Path "$FileFinal" -Algorithm SHA512 | select Hash | Foreach-Object {$_ -replace "@{Hash=", ""} | Foreach-Object {$_ -replace "}", ""})
|
Set-Variable -Name FileHash_after -Value (Get-FileHash -Path "$FileFinal" -Algorithm SHA512 | Select-Object Hash | Foreach-Object {$_ -replace "@{Hash=", ""} | Foreach-Object {$_ -replace "}", ""})
|
||||||
Write-Host "DEBUG Info: Hash Value before: $FileHash_befor"
|
Write-Host "DEBUG Info: Hash Value before: $FileHash_befor"
|
||||||
Write-Host "DEBUG Info: Hash Value after: $FileHash_after"
|
Write-Host "DEBUG Info: Hash Value after: $FileHash_after"
|
||||||
|
|
||||||
@ -220,9 +221,9 @@ Function MoveOrCopy-Item-withLogging {
|
|||||||
|
|
||||||
ELSE {
|
ELSE {
|
||||||
|
|
||||||
Set-Variable -Name FileHash_befor -Value (Get-FileHash -Path "$SourceFile" -Algorithm SHA512 | select Hash | Foreach-Object {$_ -replace "@{Hash=", ""} | Foreach-Object {$_ -replace "}", ""})
|
Set-Variable -Name FileHash_befor -Value (Get-FileHash -Path "$SourceFile" -Algorithm SHA512 | Select-Object Hash | Foreach-Object {$_ -replace "@{Hash=", ""} | Foreach-Object {$_ -replace "}", ""})
|
||||||
Set-Variable -Name FileFinal -Value (Copy-Item -Path "$SourceFile" -Destination "$DestinationPath\$FileName" -PassThru -Force)
|
Set-Variable -Name FileFinal -Value (Copy-Item -Path "$SourceFile" -Destination "$DestinationPath\$FileName" -PassThru -Force)
|
||||||
Set-Variable -Name FileHash_after -Value (Get-FileHash -Path "$FileFinal" -Algorithm SHA512 | select Hash | Foreach-Object {$_ -replace "@{Hash=", ""} | Foreach-Object {$_ -replace "}", ""})
|
Set-Variable -Name FileHash_after -Value (Get-FileHash -Path "$FileFinal" -Algorithm SHA512 | Select-Object Hash | Foreach-Object {$_ -replace "@{Hash=", ""} | Foreach-Object {$_ -replace "}", ""})
|
||||||
Write-Logfile -LogLine "The $Action command has been completed for file: $SourceFile"
|
Write-Logfile -LogLine "The $Action command has been completed for file: $SourceFile"
|
||||||
Write-Logfile -LogLine "And is now transferd to: $DestinationPath"
|
Write-Logfile -LogLine "And is now transferd to: $DestinationPath"
|
||||||
Write-Host "DEBUG Info: Hash Value before: $FileHash_befor"
|
Write-Host "DEBUG Info: Hash Value before: $FileHash_befor"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user