Home > CMS- Content Management System > Sharepoint > Archiving the files from one document library to another document library in SharePoint

Archiving the files from one document library to another document library in SharePoint

Hello everyone, in this blog we will discuss on “Archiving the files from one document library to another document library in SharePoint”.

Suppose there is a requirement to Archiving library files that are not modified last 7 years.

To accomplish above job in SharePoint, we will utilize Content Organizer feature.

Content Organizer

The Content Organizer is a SharePoint feature that can automatically manage routing documents/folders from one library to another. This not only saves time but can help make sure that a document library is managed consistently. We need to activate this feature which is available in Manage site features under Site Action. Ones we activate this feature we able to set a retention policy here we got options like Move to recycle bin, Permanently delete, Transfer to another location, start a workflow etc. To Archiving library files that are not modified last 7 years, we have option  ‘Transfer to another location’. Here we need to set up a destination connection through central admin.

If we do without a connection, we will get an error “There are no registered destination locations for this site. Select another action“.

If destination connection not setup in our site collection, we need Central Admin permission to setup this.

We can achieve archiving the files using Microsoft Flow without loss of metadata.

Steps to build Microsoft flow

We archive files of parent site Documents library to sub-site Archive library. Here my source library has 6 files. Where top 5 files are last modified date is almost 7 years passed except the last file.

 

Step 1: Recurrence

We started with a Recurrence action to set a flow to run frequently. Recurrence action has frequency option day, week even though Month, hour, seconds with timezone. Here we set flow every day at 4 PM with Indian time. 

Step 2: Get Past Time

Get past time action helps to get the date to compare, We specify 365 weeks in Interval and Time unit to get a date of the past from the current date time mean we get 7-year past date. It will automatically store it in an instance, Past time.

 

Step 4: Get Files (properties only)

In the above step, we get compared to date. Now in this action, we compare to date with a Modified date of documents of source library. Get files (properties only) action have filter query here we specify

Modified lt “<output from the previous step Get past time action>”

This will give us a list of documents to move in instance value

If you are using the default options and just specifying the site address and library name, the flow will return 100 items from the library.

If you are working with large lists Files, you can increase this limit up to the list view threshold limit which is 5,000.

To specify the number of items to be returned, expand the advanced options and specify the number in the Top Count action property.

Limit columns by view here are better to specify Use all columns (Do not limit) so it gets all metadata related source files.

Step 5: Get files metadata and content

Now in this step, we process/iterate all filtered files using Apply to each action. The value instance has an array of files so we iterate each file to get a file metadata by specifying source Site address and Identifier.

Next step is to get each file content using Get file content action. Now in this action, we once again specify source Site address and Identifier.

Step 6: Move file

This is the last step of flow. Here we specify source and destination. Specify source site address in Current site address and Identifier from Get file (properties only) action after that specify Destination site address and Destination folder or a library and in If another file is already there dropdown specify Move with a new name.

As you see, the flow will run every day at 4 PM and the result is Archive library have 5 files are successfully moved. Moving file action almost keep all file metadata whereas Copy file action will modify metadata.

Limitations:

  1. Buffer size limitationsWe can’t move files which are larger than 104 MB. If we try this we got http Bad request error “Cannot write more byte to the buffer than the configured maximum buffer size: 104857600” 
  2. Folders are not moved: We can’t move folders in the destination but files inside the folder are moved. If we try to move library containing folders, the flow will fail but files inside folders are moved in the destination with file hierarchy at same levels. So we avoid flow failure action by updating Filter Query to

     Once we specify above filter query so only files we get for the archived purpose for next process.

  3. OneNote file partially moved: OOB created OneNote files are not properly moved instead they page wise split and move in the destination. If we create an OOB OneNote file with two page, here flow will move two pages with content as it is. Here uploaded OneNote files are properly moved to the destination.
  4. Access level permission on the library/folders/files: Make sure flow owner have maximum access level permission on both library source and destination. Even though in folders and files level permission are must be needed if shared files/folders.
  5. File-level unique permission is not moved: File-level unique permission is not moved instead moved files have to set site level inherited permission.
  6. Versioning: Copy or move files we make sure destination library has versioning enabled. Otherwise, a flow will fail.
  7. Duplicate files: We have options in flow Move files action If another file is already there dropdown specify Move with a new name instead of other options like Fail this action, replace or a custom one. Once we set this option now from every time if destination library have the same file exists then flow will rename a moved file by File name digit
  8. If we try above flow with Copy file action, metadata of files are not moved so is better to keep move file action.

If you want to notify someone about ‘File-Count files are moved to Destination Library from Source Library ‘ we add a condition check to Get files action variable value. See below screen image for more idea about it.

This Article is TAGGED in , , , , . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">