Skip to content

Solution Automation CopyDuplicateFileAuto

Barbarur edited this page Sep 6, 2024 · 1 revision

Copy or Duplicate files across sites

Solution Code: CopyDuplicateFileAuto

Description

Copy or duplicate files between libraries within the same site or different sites.

Requirements

Run the solution with and account with at least SharePoint Admin role.

Parameters

Source location
Parameter Type Description
Site Url Required
choice
Site where the source files are located.
Document Library Title Required Document library where the source files are located.
Files and Items filter Optional Selects which source files will be copied. It could be all files in the document library or only some of them.
Action
Parameter Type Description
Copy Required
choice
A copy of the last version will be created. Metadata (Created, Created by, Modify and Modify By) of the new file will reflect the copy action.
Duplicate Required
choice
A full duplication will be created on the target location. All versions will be recreated and metadata will be the same as the original file.
Destination location
Parameter Type Description
Site Url Required
Choice
Destination site where the sites will be copied.
Document Library Title Required Name of the library where the files will be copied.
Server relative path Optional You can specify a folder in the document library where the files will be copied.

How this Solution works

  1. Add account as Site Collection Admin for source site.
  2. Add account as Site Collection Admin for destination site.
  3. Checks the source site exists.
  4. Checks the destination site exists.
  5. Checks the source Library exists.
  6. Checks the destination Library exists.
  7. Checks the source library exists.
  8. Checks the destination Library exists.
  9. Checks the destination folder exists.
  10. Gets all the files from the source location.
  11. Iterates through all the files and perform:
    • Copy/Duplicate item on the target location.
  12. Removes account as Site Collection Admin for source site.

Limitations

This solution covers copy and duplication of the files at the moment. Only custom metadata that exists in the source and destination library will be copied.

In the future, it is planned to include the full recreation of a Document library.

Clone this wiki locally