Copied to clipboard

Flag this post as spam?

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


  • Abebe Beso Bela 3 posts 73 karma points
    Mar 25, 2024 @ 13:59
    Abebe Beso Bela
    0

    How to remove unused media files

    I recently migrated an old site to a new one, and in the process, over 20,000 media files came along for the ride. Now, whenever I try to upload new images, the media popup just freezes up, overwhelmed by the sheer number of images under the root node. I've tested a bunch of packages that claim to fix this issue, but so far, no luck. Does anyone know a reliable way or tool to manage this?

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Mar 25, 2024 @ 14:25
    Marc Goodson
    0

    Hi Semir

    If you have access to the database, then have a look at the umbracoNode table

      SELECT TOP (1000) [id]
          ,[uniqueId]
          ,[parentId]
          ,[level]
          ,[path]
          ,[sortOrder]
          ,[trashed]
          ,[nodeUser]
          ,[text]
          ,[nodeObjectType]
          ,[createDate]
      FROM [dbo].[umbracoNode] un
      INNER JOIN umbracoContent uc
      ON uc.nodeId = un.id
      where parentId = -1 and nodeObjectType = 'B796F64C-1F99-4FFB-B886-4BF4BC011A9C' and uc.contenttypeid = 1032
    

    Essentially anything here with a parentId of -1 with this type, and is of 'image' type (1032) - is in the root of the Media Folder.

    So if there are thousands and it would take an age to manually move items one by one and you want a quick release to the historical problem of too much Media in the root, then you could create a new folder in the root, called 'OldRoot', note the Id, and then use SQL to update all the Media of type 'Image' with parentId -1, to have the parentId of your new folder - also updating the 'Path' property too to reflect the change eg from '-1, id' to be '-1, newfolderid, id' and the 'level' field (how deep the media is in the site) from '1' to be '2'

    Then rebuild the database cache and memory cache from the backoffice and then rebuild the Examine indexes...

    'quick fix - works on my machine', back up your db first! disclaimer :-)

    regards

    marc

  • Abebe Beso Bela 3 posts 73 karma points
    Mar 28, 2024 @ 10:37
    Abebe Beso Bela
    0

    Thankyou, but How does it know whether the media is used or not? I have many blog pages and the images are referenced in the markdown.

Please Sign in or register to post replies

Write your reply to:

Draft