locked
SharePoint 2007 downloading documents from multiple libraries RRS feed

  • Question

  • Hi All,

    I am working on MOSS 2007. I have a requirement to down load all the documents from all libraries on to files system maintaning the folder structure.

    The libraries have images and other document files. the libraries are present accros various subsites under a home site.

    Could you please guide me on what would be the best approach to achieve this.

    Thanks.

    Wednesday, January 21, 2015 5:38 AM

Answers

All replies

  • Hello,

    There is one OOTB solution, just open all libraries in window explorer and manually copy and paste folder/files into file system. This is good for few libraries. But if there are many then you can go with powershell script/server object code.

    In code, You can loop through all libraries and download doc in physical location. Here is ref code:

    https://dhondiyals.wordpress.com/2013/12/31/download-filesimages-from-sharepoint-libraries-using-powershell/

    http://techtrainingnotes.blogspot.sg/2014/02/download-file-from-sharepoint-using.html

    Hope it could help


    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Wednesday, January 21, 2015 5:50 AM
    Moderator
  • Hi Hemendra,

    Thanks for the reply. I need to use server onbect code.

    Could you please guide me how to do this using SOM.

    Thanks a lot.

    Wednesday, January 21, 2015 6:13 AM
  • Same class can be used in SOM as well. Use FileStream to copy doc from library to hard drive. Sample code snippet is here:

    http://blogs.msdn.com/b/varun_malhotra/archive/2008/12/15/save-files-from-sharepoint-document-library-to-file-system.aspx


    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

    • Marked as answer by letShare Wednesday, January 21, 2015 10:42 AM
    Wednesday, January 21, 2015 6:52 AM
    Moderator
  • Hi Hemendra,

    Thanks for your help. One last question. Lets say i have root site and I have subsite till the level 3 as shown below how would you loop through each site URL. Please help me on this. Thanks.

    Root
    Sub1 Sub2 Sub3
    Sub1-1 Sub2-1 Sub3-1
    Wednesday, January 21, 2015 10:45 AM
  • Here is the code:

    using(SPSite site = new SPSite(“http://sitecoll”)
    {
              foreach(SPWeb web in site.AllWebs)
              {
                        Console.WriteLine(web.ServerRelativeUrl + “: ” + web.Title);
                        web.Dispose();
              }
    }
    -or in SP context -
    foreach(SPWeb web in SPContext.Current.Site.AllWebs)
    { 
          writer.Write(web.ServerRelativeUrl + “: ” + web.Title +”,”);
          web.Dispose(); 
    }                                                                


    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Wednesday, January 21, 2015 1:11 PM
    Moderator