From 9cca4c99ccad93a495977d52653330c03e8e4790 Mon Sep 17 00:00:00 2001 From: timrademaker <10331650+timrademaker@users.noreply.github.com> Date: Fri, 22 Jan 2021 12:19:33 +0100 Subject: [PATCH] Added a rename-function to file --- vars/file.groovy | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vars/file.groovy b/vars/file.groovy index cbddaca..92df7fc 100644 --- a/vars/file.groovy +++ b/vars/file.groovy @@ -44,6 +44,14 @@ def copy(String fromPath, String toPath, Boolean force = false, Boolean recurse } } +def rename(String path, String newName, Boolean force = false) { + if(nameExists(path)) { + powershell(label: 'Rename item', returnStdout: false, script: "Rename-Item -Path '${path}' -NewName '${newName}' ${force ? '-Force' : ''}"); + } else { + log.error("Tried to rename '${path}', but this couldn't be found!"); + } +} + def zip(String pathToCompress, String destinationPath, Boolean optimalCompression = true) { if(!nameExists(pathToCompress)) { log.error("Unable to zip ${pathToCompress} as the path can't be found");