Skip to content

Enhancement: spo folder set with option to set folder color #5895

@milanholemans

Description

@milanholemans

The idea is to add some options to set the color of a folder in SharePoint.

image

Commands to update

  • spo folder rename

Caution

Currently we can only rename a folder using spo folder rename. I suggest that we rename this command to spo folder set where we can update 2 options name and color. Let's create an alias to spo folder rename so the command doesn't break. This alias can be removed in V8.

Options to add

Option Description
--color [color] Visual color of the folder. Valid values are a color name or a number. Check remarks for more info.

Remarks:

When you specify a value for color, consider the following:

Color Number value String value
Yellow 0 yellow
Dark red 1 darkRed
Dark orange 2 darkOrange
Dark green 3 darkGreen
Dark teal 4 darkTeal
Dark blue 5 darkBlue
Dark purple 6 darkPurple
Dark pink 7 darkPink
Grey 8 darkGrey
Light red 9 lightRed
Light orange 10 lightOrange
Light green 11 lightGreen
Light teal 12 lightTeal
Light blue 13 lightBlue
Light purple 14 lightPurple
Light pink 15 lightPink

Examples

Set the folder color to dark blue

m365 spo folder set --webUrl https://contoso.sharepoint.com --url '/ProjectFiles/Project-x' --color 5

Set the folder color to light teal

m365 spo folder set --webUrl https://contoso.sharepoint.com --url '/ProjectFiles/Project-x' --color lightTeal

Technical approach

We can use 3 APIs here.

  1. Keep the current API when only name is specified.
  2. Use API below when only color is specified.
POST https://tenant.sharepoint.com/sites/MySite/_api/foldercoloring/stampcolor(DecodedUrl='/sites/MySite/Projects/Project-x')
{
    "coloringInformation": {
        "ColorHex": "5"
    }
}
  1. Use API below when both options are specified.
POST https://tenant.sharepoint.com/sites/MySite/_api/foldercoloring/renamefolder(DecodedUrl='/sites/MySite/Projects/Project-x')
{
    "newName": "New folder name",
    "coloringInformation": {
        "ColorHex": "5"
    }
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions