0

Respected members of StackExchange, kindly help me with your kind suggestions to solve the issue.

I have +20,000 items in a SharePoint list that i want to move into the folders that also exists in the same list. I would like to move them according to their created date.

For example: Items created on 07-07-2013 should be moved to Folder 2013 --> July Items created on 12-10-2013 should be moved to Folder 2013 --> December

I would like to do this using C# code. If not, i can go with Power Shell script too.

Kindly share your thoughts on it. It going to be an high priority issue for me.

Regards,

3 Answers 3

1

You can move it programmatically, so that you can add your business logic as required.

To move Files to the sharepoint folders:

SPWeb oWebsite = SPContext.Current.Web;
SPFolder oFolder = oWebsite.GetFolder("Shared Documents");
SPFileCollection collFile = oFolder.Files;

/*Copy the files to a generic List of type SPFile*/
List<SPFile> listFiles = new List<SPFile>(collFile.Count);

foreach (SPFile oFile in collFile)
{
    listFiles.Add(oFile);
}

/* Enumerate the List and move the files into the subfolder.*/
foreach (SPFile moveFile in listFiles)
{
    // Here you can get the created by property and add your custom logic where to move the file.
    moveFile.MoveTo("Shared Documents/StorageFolder/" + moveFile.Name, true);
}

For other options you can also check:

http://blog-dotnetsp.blogspot.in/2010/02/move-files-between-sharepoint-document.html

0

1) Custom coding: As it is 20K items go for ContentIterator. 2) form a caml query so that the items retrieved is not more 5K(not necessary but will help in quick operation) like you have to loop each time on query farmed 3) you can fetch based on created date 4) create a folder on create date/month/year and move Item from source to destination 5) MoveTo method will be pretty fast as it is moving within the same collection. It is like remapping the reference.

ContentIterator ci = new ContentIterator(); ci.ProcessListItems(list, query, <>, false, folder, delegate(SPListItemCollection items) { foreach (SPListItem item in items) { //// add it to a collection } }, delegate(SPListItemCollection items, Exception e) { return true; });

0

I found the below link very helpful. Try it.

http://fixingsharepoint.blogspot.com/2014/07/how-to-move-sharepoint-list-items-to.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.