The Powershell module is one of the flexible ways to work with the Sitecore items with ease. If you have not installed the module yet, i highly recommend installing the Sitecore Powershell Extensions module from the Sitecore Marketplace
Here is a code snippet to update the Sitecore item fields:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) { | |
foreach($item in Get-ChildItem –Path master:\content\MyWebsite\Folder01 –Recurse) { | |
$item.Editing.BeginEdit() | |
$item.Roles = "{C731475E-D7BF-4BE1-A323-9C059ED2DE49}|{CC6FEF3F-8C13-4EC7-8E5A-9F0E56769FED}" | |
$item["__Workflow state"] = "{4785314C-2C4A-4784-955B-D638CB42E994}" | |
$item.Editing.EndEdit() | Out-Null | |
} | |
} |
The above script will be recursive and can reach items in the subfolder level. You could remove the “-Recurse” parameter if you are looking at the child items for the current folder.
The above script can scale to any other field updates or any other item or set of item updates.