SharePoint File Downloader

At Synteractive, our SharePoint deployments often have both custom functionality AND a nice UI. So (in our most interesting projects) we’ll have designers working with developers. As a result, we used to end up with one of the following situations:

  • Developers’ deployed WSP’s overwrite changes in asp, page layouts or master pages.
  • Someone wants to back up all content or styles so it can be used in another project.
  • People tiptoeing VERY CAREFULLY around each other’s code, so as not to overwrite it – but no process in place to prevent that.
  • Some unlucky person gets to copy each file, one by one, from one environment to another.   Ugh.

I started wishing that SOMEONE had created a tool to pull down our customized SharePoint content (e.g. pages, master pages, xsl, css, js) en masse, so that I could reference it later, check it into Subversion or integrate it into a WSP for later deployment to a Production environment.

Introducing SPFileDownloader

Anyone who works with me knows that I love to automate things, and of course I wanted to save time.  So I created a small program which uses SharePoint Web Services to download the contents of lists or folders specified by the user.  It’s a command line utility, but the way it’s written, it could be retooled as Powershell, Windows Forms or whatever.

Since this is a command line utility, various arguments are necessary to tell it where to get the files, authentication information, etc.  If you invoke the program without arguments, you get the following help info:
SPFileDownloader <web url> <list | list/folder/subfolder> <target dir local> <username> <password> [switches]
f   Use form-based authentication
r   Recursive - recurse through subfolders
o   Overwrite - overwrite local files
p   Pause - pause for user input after run

So a typical usage might look something like this:
> SPFileDownloader http://mysite "Style Library" c:\dev\test DOMAIN\username mypassword po

Once you get past this, the usage is self-explanatory. It can handle use form or basic authentication. You can recurse through directories (particularly useful if you want to back up the entire Style Library).

All source code is included here.   A couple of disclaimers: This code is provided as-is!  I won’t support it, though please leave comments if this has been useful to you, or if you have suggestions.   Finally, this code is, um, a bit sloppy.  It started out mostly as snippets compiled from elsewhere.  I’ve spent some time refactoring it, but it doesn’t pay to be perfectionistic here.  It works.

SPFileDownloader source code


Leave a Reply

Your email address will not be published. Required fields are marked *