Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Urvish 252 posts 776 karma points
    May 22, 2015 @ 08:51
    Urvish
    0

    Bulk delete from Media folder

    Hi,

    I am working in Umbraco 7.2.4.

    I need to delete some images and uploaded new one.

    For that I need to manualy delete images one by one.

    Is there any way to delete images in bulk from one folder?

    Any help or suggestion would be appreciate.

    Thanks in advance.

    Regards,

    Urvish Mandaliya

  • Alex Skrypnyk 6148 posts 24077 karma points MVP 8x admin c-trib
    May 22, 2015 @ 11:31
    Alex Skrypnyk
    100

    Hi Urvish,

    We are using this method in such situation, it removes all images from media section:

            /ClearMedia/
    
            public ActionResult Index()
            {
                if (ApplicationContext.Current == null) return new HttpStatusCodeResult(404);
    
                //Use the MediaService to create a new Media object (-1 is Id of root Media object, "Folder" is the MediaType)
                //Use the MediaService to Save the new Media object
                var images = string.Empty;
    
                foreach (var media in ApplicationContext.Current.Services.MediaService.GetRootMedia().Where(media => media.ContentType.Name.Equals("Image")))
                {
                    images += media + " " + media.Id + "/r/n ";
                    ApplicationContext.Current.Services.MediaService.MoveToRecycleBin(media);
                }
    
                ApplicationContext.Current.Services.MediaService.EmptyRecycleBin();
    
                return Json(new { images });
            }
    

    But try to remove this method after using or add authorization filter for security ))

    Thanks, Alex

  • Urvish 252 posts 776 karma points
    May 22, 2015 @ 11:44
    Urvish
    0

    ok Thanks Alex for the reply.

    Is there any way to delete from Umbraco back-office?

    Regards,

    Urvish Mandaliya

  • Alex Skrypnyk 6148 posts 24077 karma points MVP 8x admin c-trib
    May 22, 2015 @ 12:05
    Alex Skrypnyk
    0

    No, you can do that only via code. Thats why we suggest always upload medias in folders, it looks better and we can remove all folder.

    Thanks, Alex

  • Urvish 252 posts 776 karma points
    May 22, 2015 @ 15:10
    Urvish
    0

    ok Thanks Alex for the help.

    Regards,

    Urvish Mandaliya

Please Sign in or register to post replies

Write your reply to:

Draft