Hi,
How to upload multiple documents/images to a document library/Image library using powershell?
In the library, I have a folder called Images. I want to upload the documents to that folder.
I have checked this: http://get-spscripts.com/2010/07/upload-multiple-files-into-document.html
I have used the below powershell:
function UploadImages($weburl) { $docLibraryName = "TestLibrary" $localFolderPath = "c:\Install\Docs" Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue $web = Get-SPWeb -Identity $webUrl $docLibrary = $web.Lists[$docLibraryName] #Attach to local folder and enumerate through all files $files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles() | ForEach-Object { #Create file stream object from file $fileStream = ([System.IO.FileInfo] (Get-Item $_.FullName)).OpenRead() $contents = new-object byte[] $fileStream.Length $fileStream.Read($contents, 0, [int]$fileStream.Length); $fileStream.Close(); write-host "Copying" $_.Name "to" $docLibrary.Title "in" $web.Title "..." #Add file $folder = $docLibrary.RootFolder $spFile = $folder.Files.Add($folder.Url + "/" + $_.Name, $contents, $true) $spItem = $spFile.Item Write-Host -f Green "Added Images to ibrary !!!" } }
Here the Images are added to the Root folder. How to add to the "Images" folder inside the document library.
Thanks