I want to bulk download Media library in Sitecore Media Library after going through following solution Bulk download PDF media in Sitecore Media Library , but I found that after downloading zip file the file names are getting encoded.

Is there is any option to disabled encoding items name while downloading zip file?

Please suggest any alternate solution if its not feasible.

Update : Media Library Structure in Sitecore

enter image description here

Downloaded Zip file using Right on Media Library->Scripts->Download option

enter image description here

Thank you.

  • Probably the best option would be to write a powershell script that recurses through the media library, creating local folders if not exist then saving media item. Most likely one will exists already - maybe in SPE tasks Aug 24, 2022 at 6:46
  • Can you share a screenshot of the item name in sitecore and what it looks like after you extract it from a zip file? Aug 24, 2022 at 13:27
  • I have added screenshots. The spaces are replacing with "%20" for all Media Folder and their subitems. @MichaelWest. If I want to override existing media items then its creating new items. Aug 24, 2022 at 16:19

2 Answers 2


I got this Powershell script and found that it also downloads the file names with encoded names. So I have updated the script slightly and it now downloads all the files in your download folder with actual names i.e. without encoded.

So if the case is you need all the files only to download then it will help.

Note: It will not download in a particular folder or zip. It will download all the files in your download folder.

$location = "/sitecore/media library/Experience Explorer"
$dateTime = Get-Date -format "yyyy-MM-d_hhmmss"
$zipName = "test"
$dataFolder = "C:\inetpub\wwwroot\Sitecore10.1sc.dev.local\App_Data" #[Sitecore.Configuration.Settings]::DataFolder
$zipPath = "$dataFolder/$zipName-$datetime.zip"

$sourcedir = "/sitecore/media library/Experience Explorer"

[System.Reflection.Assembly]::Load("WindowsBase,Version=, `
  Culture=neutral, PublicKeyToken=31bf3856ad364e35") | Out-Null
$ZipPackage=[System.IO.Packaging.ZipPackage]::Open($zipPath, `
  [System.IO.FileMode]::OpenOrCreate, [System.IO.FileAccess]::ReadWrite)
$items = gci -recurse $sourceDir
[byte[]]$buff = new-object byte[] 40960
$i = 0;
ForEach ($item In $items) 
  $mediaItem = New-Object "Sitecore.Data.Items.MediaItem" $item;
  $mediaStream = $mediaItem.GetMediaStream();
  $fileName = Resolve-Path -Path $item.ProviderPath -Relative
  $nm = $item.Name + "." + $item.Extension
  Write-Host $nm
  $fileName = "$fileName.$($item.Extension)" `
    -replace "\\","/" -replace "./", "/"
  # Print out the file - the list will show up once the file is downloaded
  "Added: $fileName"
  # Show progress for the operation
  Write-Progress -Activity "Zipping Files " `
    -CurrentOperation "Adding $fileName" `
    -Status "$i out of $($items.Length)" `
    -PercentComplete ($i *100 / $items.Length)
  $partUri = New-Object System.Uri($fileName, [System.UriKind]::Relative)
  $partUri = [System.IO.Packaging.PackUriHelper]::CreatePartUri($partUri);
  $part = $ZipPackage.CreatePart($partUri, `
    "application/zip",  `
  do {
    $count = $mediaStream.Read($buff, 0, $buff.Length)
    $stream.Write($buff, 0, $count)
  } while ($count -gt 0)
  Out-Download -Name $nm -InputObject $stream

You can use this but you need to modify this further if you want to enhance the functionality.


I guess you are creating the Sitecore package and not downloading the media. With Sitecore PowerShell, you need to right-click on the media folder and click the Download button. It will ask you to download the media items as .zip, where the file name will be the media item name. see below screenshot -

enter image description here

Update:- OOTB Sitecore's SPR package script for media download is using System.IO.Packaging library which has some limitations and because of this you will not able to update or rename the file name in the downloaded zip. In most cases, the space changed into %20for Sitecore items (Sitecore does not allow special char in item name). There are two options for this-

  • Write a custom PowerShell script in Sitecore using some third-party library such as SharpZipLib, but this is going to be a complex thing as you need to download it put is somewhere on server to take reference in SPE script and understand it's coding API.

  • Download the images using OOTB download options, then extract it and run the below or similar to below Windows PowerShell command to rename the file names -

    Get-ChildItem -File * -Recurse| Rename-Item -NewName { $_.Name -replace '\%20',' ' }
  • Thank you for quick response. I have tried with both options Packaging and with Download Option as well but Both are downloading with zip file with encoded files names. Aug 24, 2022 at 8:17
  • Above comment UPDATE - I have tried with download option only. Aug 24, 2022 at 12:33
  • Thank you. l will try it. Aug 25, 2022 at 5:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.