Powershell Script to dump all the folders from one list to another in same or different site collection with metadata . Try it on sample list and test first .
function Copy-ItemsToFolder([Microsoft.SharePoint.SPFolder]$folder, $srcList, $destList)
{
$spQuery = New-Object Microsoft.SharePoint.SPQuery
$spQuery.Folder = $folder
$sourceSPListItemCollection = $srcList.GetItems($spQuery);
$destFolder = $destList.Folders[$folder.Name];
if ($destFolder -eq $null -or $destFolder -eq "")
{
#folder does not exist so create it.
$destFolder = $destList.AddItem("", [Microsoft.SharePoint.SPFileSystemObjectType]::Folder)
$destFolder["Title"] = $folder.Name ;
$destFolder.Update()
}
$count = $sourceSPListItemCollection.Count;
$index = 0;
$newFolderPath = $destFolder.Folder.ServerRelativeUrl
foreach($srcListItem in $sourceSPListItemCollection)
{
$index++;
write-host "adding new item $index of $count";
$newSPListItem = $destList.AddItem($newFolderPath, [Microsoft.SharePoint.SPFileSystemObjectType]::File, $null);
foreach($spField in $srcListItem.Fields)
{
if ($spField.ReadOnlyField -ne $True -and $spField.InternalName -ne "Attachments")
{
$newSPListItem[$spField.InternalName] = $srcListItem[$spField.InternalName];
}
}
$newSPListItem.Update()
write-host "added";
}
}
try
{
$srcListSiteUrl = "https://sitename/abc/"
$SourceListName = "lsitname"
$dstListSiteUrl = "https://sitename/def/"
$DestinationListName = "lsitnamearchieve"
$keyColumnInternalName = "Title"
$sourceListWeb = Get-SPWeb -identity $srcListSiteUrl
$sourceListUrl = $sourceListWeb.ServerRelativeUrl + "/lists/" + $SourceListName;
$dstListWeb = Get-SPWeb -identity $dstListSiteUrl
$destinationListUrl = $dstListWeb.ServerRelativeUrl + "/lists/" + $DestinationListName;
$SourceList = $sourceListWeb.GetList($sourceListUrl);
$DestinationList = $dstListWeb.GetList($destinationListUrl);
foreach($currentFolder in $SourceList.RootFolder.SubFolders)
{
Write-Host "processing folder $($currentFolder.Name)";
if ($currentFolder.ItemCount -gt 0)
{
Copy-ItemsToFolder $currentFolder $SourceList $DestinationList
}
Write-Host "done with folder"
}
}
catch
{
write-host $_.exception
}
finally
{
if($sourceListWeb -ne $null){$sourceListWeb.Dispose()}
if($dstListWeb -ne $null){$dstListWeb.Dispose()}
}