From 237e9c3106a0754137279477f34cca050f2bd3b5 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Sun, 8 Jan 2023 23:18:40 +0100 Subject: [PATCH] Copy file/directory in Mod Template/Functions --- Winget-AutoUpdate/mods/_AppID-template.ps1 | 10 ++++++++++ Winget-AutoUpdate/mods/_Mods-Functions.ps1 | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Winget-AutoUpdate/mods/_AppID-template.ps1 index 07ac85b..e824b73 100644 --- a/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -32,6 +32,13 @@ $DelValue = "" #Remove file/directory, multiple: "file1","file2" $DelFile = @("") +#Copy file/directory +#Example: +#$CopyFile = "C:\Logfiles" +#$CopyTo = "C:\Drawings\Logs" +$CopyFile = "" +$CopyTo = "" + <# FUNCTIONS #> . $PSScriptRoot\_Mods-Functions.ps1 @@ -57,5 +64,8 @@ if ($DelKey) { if ($DelFile) { Remove-ModsFile $DelFile } +if ($CopyFile -and $CopyTo) { + Copy-ModsFile $CopyFile $CopyTo +} <# EXTRAS #> diff --git a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 4ccb78e..e57e53a 100644 --- a/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -168,3 +168,11 @@ function Remove-ModsFile ($DelFile) { } Return } + +function Copy-ModsFile ($CopyFile, $CopyTo) { + if (Test-Path "$CopyFile") { + Copy-Item -Path $CopyFile -Destination $CopyTo -Recurse -Force -ErrorAction SilentlyContinue | Out-Null + } + Return +} +