Copy Files between SharePoint Document Libraries Using Power Shell

Advertisement
      I am having a Site Collection, in that am having two document library’s, once library having files i want to copy the same files to move the another library.
Using the below power shell I implemented this.

Add-PsSnapin Microsoft.SharePoint.PowerShell
#Refereing the SiteCollection URL
$web = "http://dotnetsharepoint:1234/sites/sharepoint/"
#Refereing the Source DocumentLibray Having Files
$sourLibrary = (Get-SPWeb $web).Folders["SourceLibraryName"]
#Refereing the Destination of DocumentLibray to place Files
$destLibrary = (Get-SPWeb $web).Folders["DestinationLibraryName"]

$destFiles = $destLibrary.Files
foreach ($file in $sourLibrary.Files)
{
    $currentFile = $file.OpenBinary()
    $destURL = $destFiles.Folder.Url + "/" + $file.Name
    $destFiles.Add($destURL, $currentFile, $true)




Advertisements
SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a comment