2013-02-13 28 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語句會工作。 此外,這會自動更改可能出錯的地方,因此請務必先在開發/用戶環境中執行此操作,然後再備份生產中的內容數據庫並最終放棄。

相關問題