Copy file/directory in Mod Template/Functions

pull/257/head
KnifMelti 2023-01-08 23:18:40 +01:00
parent 72bcf77672
commit 237e9c3106
2 changed files with 18 additions and 0 deletions

View File

@ -32,6 +32,13 @@ $DelValue = ""
#Remove file/directory, multiple: "file1","file2" #Remove file/directory, multiple: "file1","file2"
$DelFile = @("") $DelFile = @("")
#Copy file/directory
#Example:
#$CopyFile = "C:\Logfiles"
#$CopyTo = "C:\Drawings\Logs"
$CopyFile = ""
$CopyTo = ""
<# FUNCTIONS #> <# FUNCTIONS #>
. $PSScriptRoot\_Mods-Functions.ps1 . $PSScriptRoot\_Mods-Functions.ps1
@ -57,5 +64,8 @@ if ($DelKey) {
if ($DelFile) { if ($DelFile) {
Remove-ModsFile $DelFile Remove-ModsFile $DelFile
} }
if ($CopyFile -and $CopyTo) {
Copy-ModsFile $CopyFile $CopyTo
}
<# EXTRAS #> <# EXTRAS #>

View File

@ -168,3 +168,11 @@ function Remove-ModsFile ($DelFile) {
} }
Return Return
} }
function Copy-ModsFile ($CopyFile, $CopyTo) {
if (Test-Path "$CopyFile") {
Copy-Item -Path $CopyFile -Destination $CopyTo -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
}
Return
}