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
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
http://vspug.com/dez/2007/11/30/moving-copying-documents-between-libraries-with-metadata-including-version-history/
http://blogulous.wordpress.com/2008/02/20/copying-documents-between-sharepoint-libraries-keeping-version-history-part-1/
http://sphelpdesk.spaces.live.com/blog/cns!D9676F3678CF7BE7!173.entry
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)
{
listFiles.Add(oFile);
}
// 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.
http://geek.hubkey.com/2007/12/move-sharepoint-document-library-files.html?m=1
-
I will try these options and let you know if it works..thank you. 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. 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 ? Commented Nov 5, 2015 at 19:43