I have two document libraries one is DocLib-A and other DocLib-B I now have to move documents from library A to Library B depending on certain time period say 2 months old. If documents in Lib A are 2 months old than should be moved to library B. I know there is copy option in workflow but how can i use to do same depending on time factor. If there is any alternate option other than workflow. Can some one suggest on this. Thanks for help in advance.

2 Answers 2


If you want to do it through workflow then you can do it through SPD


If you also want to copy history, then use following URL


By normal code :

To Move files from one location to another, use one of the MoveTo()methods of the SPFile class.

public void Movefiles(destlibUrl)
SPWeb web = SPContext.Current.Web;
SPFolder oFolder = web.GetFolder(“Source Library”);
SPFileCollection collFile = oFolder.Files;

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

foreach (SPFile oFile in collFile)

// Enumerate the List and move the files into the Destination library.
foreach (SPFile moveFile in listFiles)
moveFile.MoveTo(“destlibUrl/” + moveFile.Name, true);

You can also have a look at already solved solutions for your requirement.




  • I will try these options and let you know if it works..thank you.
    – SPLearner
    Commented Nov 5, 2015 at 19:37

You can use the Information Management Policy feature in Library A. You would add the retention policy to the content types you have included in Library A (Documents, for example) and set the expiry for 2 months. Once the document 'expires', you can transfer it to another location.

In order for this to work, you will need the Content Organizer feature on your site enabled, and use the submission point (which is the Content Organizer Drop off Library) as your transfer location within the policy. You can then set up a rule within the content organizer to direct everything in the drop off library to Library B.

  • to set up this i should have access to central administration in that case I don't have that access in my case.
    – SPLearner
    Commented Nov 5, 2015 at 19:36
  • You don't need access to CA to enable Content Organizer. You just need to be able to access your site settings. It's a feature within the site. Commented Nov 5, 2015 at 19:37
  • Yes i have that option activated but how can i set up rule in organizer and when i choose transfer to other location from the information management policy it is showing there are no registered destination locations for this site. Select another location. Any idea why is this ?
    – SPLearner
    Commented Nov 5, 2015 at 19:43

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.