Skip to content

Commit

Permalink
Merge pull request #2 from nddipiazza/rename-folder
Browse files Browse the repository at this point in the history
rename folder
  • Loading branch information
nddipiazza authored Sep 18, 2020
2 parents 722d098 + 481c287 commit 3d79154
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# sputil-docker
Dockerbuild for an SP utilility
Dockerbuild for an SP utility


# how to publish a new version

Merge your change. Create a tag.

run `docker build .` from the root directory. It will publish the tag to docker.

The result, you can then use the new docker image:

Example:

`ndipiazza/sputil_mono:0.0.4`



Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,6 @@ class Program {
string password;
List<Dictionary<string, object>> actions;

public static void RenameFile(ClientContext ctx, string fileUrl, string newName) {
var file = ctx.Web.GetFileByServerRelativeUrl(fileUrl);
ctx.Load(file.ListItemAllFields);
ctx.ExecuteQuery();
file.MoveTo(file.ListItemAllFields["FileDirRef"] + "/" + newName, MoveOperations.Overwrite);
ctx.ExecuteQuery();
}

static SecureString GetSecureString(string input) {
if (string.IsNullOrEmpty(input))
throw new ArgumentException("Input string is empty and cannot be made into a SecureString", nameof(input));
Expand Down Expand Up @@ -569,6 +561,14 @@ void exec() {

res.Add("" + item.Id);
}
} else if (actionType.Equals("renameFolder")) {
using (ClientContext clientContext = getClientContext(removeHttpsFromUrl((string)action["ParentSiteUrl"]))) {
var from = (string)action["FromFolderUrl"];
var to = (string)action["ToFolderUrl"];
var folder = clientContext.Web.GetFolderByServerRelativeUrl(from);
folder.MoveTo(to);
clientContext.ExecuteQuery();
}
} else if (actionType.Equals("moveFiles")) {
using (ClientContext clientContext = getClientContext(removeHttpsFromUrl((string)action["ParentSiteUrl"]))) {
// FromFolderUrl and ToFolderUrl are ServerRelativePaths such as /sites/nick_test/Shared Documents/test1
Expand Down

0 comments on commit 3d79154

Please sign in to comment.