I have a Task to move data of Document Library from on Site to sub site, below is the situation, Using office 365 Need to migrate a library and its folder to a sub site where folders would be treated as libraries in that sub site The size of the library is 3.29 GB. I have to write a custom code for this. The various details of the documents etc must be restored like the modification date, version history etc.
You need to save the Document Library as template including its content:
- Go to the library you would like to migrate, click LIBRARY in the upper left corner> click Library Settings.
- Click Save document library as template > type in the File name and the Template name > select "Include Content" > click OK. Then the template has been saved to List Template Gallery.
- Go to the destination site, click Site Contents > click add an app.
- In the search box, type in the name of the template you have created to create a new library. The newly created library is the same as the one in another site.
Reference: SharePoint Online - Migrate document library