I want to rename items with specific name in my Sitecore content tree using PowerShell script to a new name. I tried the following but no change-
Set-Location -Path master:\content\HyperLocal\Arena\
$itemcount = 0
Get-ChildItem -Recurse | ForEach-Object {
$rendering = Get-Rendering -Item $_
if((!([string]:: IsNullOrEmpty($rendering))) -and $_.Name.Contains("renamemeabhishek"))
{
$itemcount = $itemcount + 1
$NewName = $_.Name.Replace("renamemeabhishek", "iamrenamed")
$ItemPathOnly = $_.FullPath.Substring(0, $_.FullPath.LastIndexOf("/"))
$NewItemPath = Join-Path $ItemPathOnly -ChildPath $NewName
$oldName = Join-Path $ItemPathOnly -ChildPath $_.Name
Move-Item $oldName $NewItemPath
Write-Host "$OldName renamed to $NewItemPath"
if ((!([string]::$_."__Display Name")) -and $_."__Display Name".Contains("renamemeabhishek"))
{
$_."__Display Name" = $_."__Display Name".Replace("renamemeabhishek","iamrenamed")
}
# - This line below resets the display name to the item name, in essence
# - nullifying the Display Name property
#Reset-ItemField -Item $ _ -IncludeStandardFields -Name "_Display Name"
}
}
Write-Host "Task Completed - Item Count: " $itemcount
I want to rename this "renamemeabhishek" item under following path to a new name or item with similar name to the new name given. Please suggest.