Create/Rename/Modify content types

Some content types are hidden. This makes it hard to create a new content type, which inherrits from e.g. the “event”. Via the object model it is very easy to create a content type, which uses e.g. “event” as parent.

SPSite site = new SPSite( http://serverurl);
SPContentType parentContentType = site.RootWeb.ContentTypes[“Event”];
SPContentType newType = new SPContentType(parentContentType, site.RootWeb.ContentTypes, “newName”);
site.RootWeb.ContentTypes.Add(newType);

Because creating a new content type is just not enough, I wrote a little console application, which lets you create, rename and delete content types for a sitecollection:

Usage:
SharePointConsole http://siteurl Command [Parameter1 Parameter2]
Commands:
– EnumContentTypes
– CreateContentType
– RenameContentType
– DeleteContentType

EnumContentType siteurl:
Returns all content types from the specified sitecollection.

CreateContentType newName [ContentType]:
Creates a new content type and inherrits from an exiting one, if a parent content type is specified.

RenameContentType contentType newName:
Renames a content type

DeleteContentType siteurl Name:
Deletes a content type

You can download this tool here, and the Visual Studio Project with sourcecode here.