2013-02-13 53 views
1

你们得救我。 我应该进入70多个SharePoint 2013页面,并用正确的复制版本手动替换每个页面的html中的每个3+链接。如在,所有的链接目前指向/ place1/place2 /链接,现在他们需要/ place3/place4 /链接有没有办法一次编辑多个SharePoint 2013页面的HTML?

所以,必须有一种方式来批量编辑所有的页面,如找到并替换,否则我只想坐在角落里哭几个小时。我无法编辑文件夹结构,因为我不是项目负责人。

我会尽一切努力保持我的理智。

+0

如果这些文件位于同一个(或几个)位置,则应将其复制到您的机器。如果页面位于库中,则可以使用资源管理器视图来复制它们。然后你运行一个改变链接的脚本。现在是学习PowerShell(假设你使用Windows)和正则表达式的好时机! – 2013-02-13 23:58:03

回答

2

你可以使用powershell。 从this question

function ProcessWeb($currentWeb) 
{ 
    if([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($currentWeb)) 
    {    
     $publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($currentWeb) 
     $publishingPages = $publishingWeb.GetPublishingPages() 
     foreach ($publishingPage in $publishingPages) 
     { 
      if($publishingPage.ListItem.File.CheckOutStatus -eq "None") 
      { 
       UpdatePage -page $publishingPage 
      } 
     }  
     Write-Host -ForegroundColor red "FINISHED" 
    } 
    else 
    { 
     Write-Host -Foregroundcolor Red "^ not a publishing site" 
    } 
} 

function UpdatePage($page) 
{ 
    $page.CheckOut(); 
    Write-Host -Foregroundcolor green $page.Url;   
    $NewPageContent = $page["PublishingPageContent"].Replace("/place1/place2/link","/place3/place4/link"); 
    $page["PublishingPageContent"] = $NewPageContent  
    $page.ListItem.Update(); 
    $page.CheckIn("nothing"); 
    $page.ListItem.File.Approve("Updated PublishingPageContent to replate place1/place2 with place3/place4"); 
} 

ProcessWeb(Get-SPWeb -identity http://myintranet.com) 

请注意,您将需要制定出一个良好的如何REPLACE语句会工作。 此外,这会自动更改可能出错的地方,因此请务必先在开发/用户环境中执行此操作,然后再备份生产中的内容数据库并最终放弃。

相关问题