1

I tried different ways to move a file from one library to another library on the same site (SharePoint Online). The file is moved but the modified date and modified user are overwritten. Worse the modified user is changed for all history versions of the moved file.

If i move a folder, files inside folder does not changes.

I tried:

SP.MoveCopyUtil.moveFile(pageContext, itemUrl, destinationUrl + fileName);

-

file.moveTo(libraryUrl + fileName, 1);
sessionState.AppContext.executeQueryAsync(
    success,
    fail
);

-

var fileCollectionEndpoint = spAppWebUrl + "/_api/sp.appcontextsite(@target)/web/getfilebyserverrelativeurl('" + sourceFolderUrl + "')" +
    "/moveto(newurl='" + libraryURL + fileName + "',flags=1)?@target='" + targetSiteUrl + "'";
// Send the request and return the response.
// This call returns the SharePoint file.
return $.ajax({
    url: fileCollectionEndpoint,
    type: "POST",
    headers: {
        "accept": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val()
    },
    success: success,
    error: fail
});

How to achieve a moveTo and maintain all file info unmodified?

Maelig
  • 2,046
  • 4
  • 24
  • 49
Gremik
  • 11
  • 3
  • You could try moving the file onto a new directory and then moving the directory to another library and then moving the file out of the directory and removing the directory. This might work. But I can't test it. – Dan D. Jan 31 '19 at 10:04

0 Answers0