Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Bulk deletion of images from MB container
Shete
Hi,
I want to delete images in bulk from containers but not container. Some of the MB containers have images >20K. We are using MB 4.6.1 ver.
Currently I am trying to delete 90 days old images using following code. I found that if image count is appx greater than 10K then mbServer.GetAssetList doesn't return anything. Is there any way to query in batches?
Or it would be great if you can suggest any alternate solution.
Thank you,
Shete
MediaBin mbServer = new MediaBin("serverNAme");
try
{
MBAsset[] assets = mbServer.GetAssetList("{container GUID}");
foreach (MBAsset asset in assets)
{
MBMetadata data = mbServer.MediaBinServer.GetAssetMetadataItem(asset.mID, "{5BE195E7-0726-11D3-9DDE-0060081F836F}");
DateTime insertDate = (DateTime)data.mValue;
DateTime currentDate = DateTime.Now;
TimeSpan ts = currentDate.Subtract(insertDate);
if (ts.Days > 90)
{
// delete asset
mbServer.DeleteAsset(asset.mId, asset.revision);
}
}
}
catch (Exception e)
{
file.WriteLine(e.Message);
}
Find more posts tagged with
Comments
msnider
Instead of doing an iteration over the entire contents of a container, you should do a search within that container for assets whose insertion date are older than 90 days. That would return a much smaller set of assets to delete.
In doing this, you should use Search_GetAssetIDsOnly which is a much faster call then the standard Search call.
Mark
Shete
Thank you Mark for reply.
Yes, as suggested by you I can query container directly with the given criteria. I will get a string array of assetIds. Now I will have to again iterate through the list to delete assets. Is there any better way to bulk delete images on given criteria? I am looking for bulk image deletion in faster way.
Thanks
Shriram
msrinivas
Just a suggestion.......bulk delete is usually not a bright idea!!
You might instead want to consider moving them to an "archive" or "to be deleted" folder and have someone verify the images there before actually deleting them.
Though MB has a "Deleted Items" folder that keeps images for a while it might actually not be easy to find the ones that you are looking for if you have a lot of images in the deleted items folder.
HTH