3

I created several content types for folders to define custom default views depending on the content of the folders.

However it is quite cumbersome if I need to click on Edit properties for each single folder one by one.

Is there an easy way to select several folders and change their content type?

I tried to create a view which displays the content type, which works well. But if I try to modify it in QuickEdit, the column can not be changed.

4

This can be done by using SharePoint administration Shell.

You need to retrieve the list and loop through folders. If the folder content type is used, you replace the content type.

# Get your site collection first
$site = Get-SPSite -Identity http://mysitecol

#if your list is in the top web:
$web = $site.RootWeb
# or if your list is in a subsite:   $web = $site.OpenWeb("/mysubweb")

#then you can get your list:
$list = $web.Lists["my list display name"]

$folderCTName = "Folder"
# your content type id looks like 0x0120...... 
$myCTId = "<EnteryourContentTypeIDHere>"

#finally you loop through each folder, and if the content type is default folder CT, you replace it by your own content type
for($count = $list.Folders.Count; $count -ge 0; $count--)
{
    $curItem = $list.Folders[$count]
    if ($curItem.ContentType.Name -eq $folderCTName)
    {
                $curItem["ContentTypeId"] = $myCTId
                $curItem.SystemUpdate($false)
    }
}

it worked on my environment

  • good idea . where is case study of uses of this idea that others extend for their organizations how can i find those ideas? – saber tabatabaee yazdi Jan 14 '17 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.