You can extend a Download script
(/sitecore/system/Modules/PowerShell/Script Library/SPE/Maintenance/Media Library Maintenance/Content Editor/Context Menu/Download) which is provided out of the box and store your file under SitecoreDataFolder
(/App_Data).
So you can create a zip file for all the media items and store them in SitecoreDataFolder. Comment out the download and remove the zip code at the end of the script. So it will stay there in /App_Data folder.
function ZipItems( $zipArchive, $sourcedir )
{
Set-Location $sourcedir
[System.Reflection.Assembly]::Load("WindowsBase,Version=3.0.0.0, `
Culture=neutral, PublicKeyToken=31bf3856ad364e35") > $null
$ZipPackage=[System.IO.Packaging.ZipPackage]::Open($zipArchive, `
[System.IO.FileMode]::OpenOrCreate, [System.IO.FileAccess]::ReadWrite)
$items = @(Get-Item $sourceDir) + (Get-ChildItem -recurse $sourceDir)
[byte[]]$buff = new-object byte[] 40960
$i = 0;
ForEach ($item In $items) {
$i++
if([Sitecore.Resources.Media.MediaManager]::HasMediaContent($item)){
$mediaItem = New-Object "Sitecore.Data.Items.MediaItem" $item;
$mediaStream = $mediaItem.GetMediaStream();
$fileName = Resolve-Path -Path $item.ProviderPath -Relative
$fileName = "$fileName.$($item.Extension)".Replace("\","/").Replace("./","/");
"Added: $fileName"
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", [System.IO.Packaging.CompressionOption]::Maximum)
$stream=$part.GetStream();
do {
$count = $mediaStream.Read($buff, 0, $buff.Length)
$stream.Write($buff, 0, $count)
} while ($count -gt 0)
$stream.Close()
$mediaStream.Close()
}
}
$ZipPackage.Close()
}
$location = get-location
$time = Get-Date -format "yyyy-MM-d_hhmmss"
$zipName = Split-Path -leaf $location | % { $_ -replace " ", ""}
$zipPath = "$($SitecoreDataFolder)\$zipName-$time.zip"
ZipItems $zipPath $location
Download-File -FullName $zipPath > $null
Remove-Item $zipPath
Close-Window
Refer this article that provide more context: https://www.nehemiahj.com/2022/05/download-multiple-media-files-from.html
Hope it helps!