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.


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)

/* 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:

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; });

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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