How do I retain metadata on a sharepoint 2010 Document Library when moving from one site to another?

We have a document library within our main SharePoint 2010 site.  This document library has custom columns added where the users can add descriptions to the files they upload.

Recently we've had the need arise where we had to make these files available to external users.  So in order to do that and keep the rest of our SharePoint data secure, we created a separate SharePoint site and made it available to the outside.

The problem I'm having now is I need to be able to move this document library over to the new site and retain all of the metadata that was added in those custom columns.

I've been told be a local consulting company that the only way to do this is to pay for tool that charges by the gb (we currently have over 25gb of files in the document library).

Does anyone now of an easy way to do this or can we even script this migration with .NET?

Thanks.
maximjonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

colly92002Commented:
Easiest way (provided you want to copy the whole list) is simply to do a backup and restore.

you can backup a list in powershell:
Export-SPWeb -Identity http://<your site url> -Path C://listBackup.cmp -ItemUrl <relative path to list>

Open in new window


Restore to other site:
Import-SPWeb -identity http://<your other site url> -Path C://listBackup.cmp -UpdateVersions Overwrite

Open in new window



If you do this you will want to clear down the target list every time you refresh it, which can be done like this:

#Add-PSSnapin Microsoft.SharePoint.PowerShell

# Replace siteurl with actual web url
$web = Get-SPWeb -Identity "http://<your other site>"
# Replace docurl with document library url
$list = $web.GetList("<relative path to list>")

function DeleteFiles {
    param($folderUrl)
    $folder = $web.GetFolder($folderUrl)
    foreach ($file in $folder.Files) {
        # Delete file by deleting parent SPListItem
        Write-Host("DELETED FILE: " + $file.name)
	$list.Items.DeleteItemById($file.Item.Id)
    }
}

# Delete root files
DeleteFiles($list.RootFolder.Url)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
maximjonAuthor Commented:
This was perfect!  Thank you so much!  I was originally told by consultants that the only way to do this was to buy a 3rd party product.  You literally saved my company thousands of dollars.  Thank you!
0
colly92002Commented:
No problem, happy to help :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.