Skip to content

Commit

Permalink
Added a rename-function to file
Browse files Browse the repository at this point in the history
  • Loading branch information
timrademaker committed Jan 22, 2021
1 parent b644c2c commit 9cca4c9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vars/file.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 9cca4c9

Please sign in to comment.