As @SitecoreClimber suggested, the best approach to do this is to install Sitecore PowerShell Extensions and fix this with PowerShell. If you don't have admin access or you are not allowed to install PowerShell extensions to your machine, you can use the following .NET code to achieve what you want. Just replace the values of ID
variables with the IDs of your templates and sublayouts:
// replace with the first template's ID
ID template1ID = new ID("{A0F73C76-DD4D-4037-90D4-48B616397F5D}");
// replace with the second template's ID
ID template2ID = new ID("{43A1EBB0-CABB-4682-9F5B-7765D7FB0E29}");
// replace with your sublayout's ID
ID sublayout2ID = new ID("{1C6094FA-4539-48E4-A24A-104787641A88}");
Database masterDatabase = Factory.GetDatabase("master");
TemplateItem template2Item = masterDatabase.GetTemplate(template2ID);
// Set to your RootItem
Item rootItem = masterDatabase.GetItem("{756B23C8-1C0F-41AC-9273-B18FDA047925}");
using (new SecurityDisabler())
{
foreach (Item child in rootItem.Axes.GetDescendants())
{
RenderingReference[] renderings = child.Visualization.GetRenderings(Sitecore.Context.Device, true);
IEnumerable<RenderingReference> sublayout2Renderings =
renderings.Where(x => x.RenderingID == sublayout2ID);
foreach (RenderingReference rendering in sublayout2Renderings)
{
if (!string.IsNullOrEmpty(rendering.Settings.DataSource))
{
Item datasourceItem = masterDatabase.GetItem(rendering.Settings.DataSource);
if (datasourceItem != null)
{
if (datasourceItem.TemplateID == template1ID)
{
datasourceItem.ChangeTemplate(template2Item);
}
}
}
}
}
}