Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a requirement that states that I need to move files into Document Sets where the Document Set is equal to the value of a column named DS. The files and the document sets are in the same library. There are 100's of files and documents sets in this library. I can use either PowerShell or Workflow.

I have the following powerShell Script that has been posted all over the web:

$siteURL="myUrl"
$docLib = "PST"
$site=Get-SPSite $siteURL
$web=$site.RootWeb
$collFiles=$web.GetFolder($docLib).Files
$count=$collFiles.Count
while($count -ne 0)
{
$item = $collFiles[$count-1].Item
$DocSet = $item["DS"]
Write-Host "$DocSet is the doc set. $collFiles[$count-1].Name is name"
$collFiles[$count-1].MoveTo($siteURL + "/" + $docLib + "/" + $DocSet + "/"  + $collFiles[$count-1].Name, $true)                       
$count--
}

When I run it, it does not move the files. What am I missing here?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.