SOLVED Methods of Mass File Selection (for deletion)


Jul 12, 2017
cPanel Access Level
Website Owner
New member so just to confirm - intro post - check, methods of effective post - check, search existing - check.
One thing - the 'run this code to give system info' - i have no idea where/how to do that - i hope that doesn't immediately put me in the category of 'idiot best ignored' :)

Top level of shared hosting via godaddy. Rapidly outgrowing limitations (which doesn't take much). Need to make jump to VPS or Dedicated - it's on my list and this query is in part connected. Some system info below.

I have an increasingly urgent need to select files from multiple folder tiers and subfolders within the 'uploads' folder of my public html.

I need a way of selecting files on a wildcard basis.

I have 195,000 files, 150,000 of them are media files in the uploads folder (and about 48 subfolders on 3 tiers).

This is reaching hosting limits, and results in a pretty unwieldy install so far as back ups etc are concerned (and will make moving servers an unnecessarily big job).

Of the 150k media files, about 80,000 are old wp-theme generated image sizes that will never be needed again.

All those I need throughout the folder tree can be defined by 6 wildcard patterns, e.g. " *300x724.* "

it would give an extra level of protection in only getting the right files if i could also select " date modified < date " ,but that isn't a dealbreaker.

quite an easy job on my destop, but i can't figure a way to do it in cpanel. certainly not from the search inside file manager which just gives nil returns.

it is quite a hard subject to search on - file deletion just returns every panic thread from someone who has deleted something critical, file search wildcard seems to give loads about a cpanel wildcard project, etc etc.

i thought to copy them all out to my local drive and do it there before reuploading - but I am in Ibiza where our connections are about 20 years behind what most of you guys are used to - i use a satellite internet service that would throttle me for the month if i tried to do anything like that big a job in one hit. and it seems sledgehammer and nut anyway.

not that it is really relevant to the job - in case anyone is interested, my theme serves photos in a way that is extremely efficient in terms of web speed, but has the effect of making a huge media collection. Every photo uploaded is recreated in 10 different sizes used around the theme. I just upgraded the theme and they have used all new sizes, and in the install notes they said to regenerate images BEFORE the step where you decide what image sizes you will need, there are about 25 variations. So i now have about 35 images for every actual original image.

there are one or two wordpress plug ins theoretically designed to clean up media trash, but they are very glitchy and there is no way they will get the resources needed to run on shared hosting.

asking godaddy is about as pointless as asking my grandmother, after an interminable wait they will just try to get me to buy something, and i'm already on their max plan for shared and am determined to look elsewhere for a server.

so, that is my problem. how to delete about 80,000 media files selectively on wildcard criteria.

did you need to know all that? well forums always say give more info, so there it is.

here is a bit of system info
PHP Version : 5.6.30
PHP Memory Usage: 37.88 MB
PHP Memory Limit : 256M
PHP Max Upload Size : 32M
PHP Max Post Size : 64M
PHP Allow URL fopen : On
PHP Allow URL Include : Off
PHP Display Errors : Off
PHP Max Script Execution Time : 150 Seconds

Thanks in anticipation.



Staff member
Apr 11, 2011
Hello Nick,

Ideally, you'd use SSH for this type of action because it's easy to search for files using the "find" command and then have all of the files listed in the search results deleted with the "rm" command. You may want to check with your hosting provider to see if SSH access is available. If so, we document how to access the server via SSH at:

SSH Access - Documentation - cPanel Documentation

Without SSH access, you are likely limited to using File Manager or FTP to remove the files. Filezilla is one FTP client that offers the ability to remove specific types of files. Here's a third-party URL where this is discussed:

How to recursivelly delete all files with certain name with FileZilla

Thank you.
  • Like
Reactions: gibbsyns3


Jul 12, 2017
cPanel Access Level
Website Owner
Brilliant Michael, thank you.
I do have ssh available, i have enabled it generated keys etc, but getting to a simple command prompt I find kind of daunting.
To avoid the possibility of being back on here tomorrow with a 'what do i do to fix a site i've ruined through ssh' post, i have used the familiar filezilla method.
easy, fast, and my first image size search has found the expected 4,500 files, so i estimate a clean up of around 80,000 files in total.
the downside is that it is not deleting them into the server trash, but i'll just need to take care.
search 'clean up wordpress media files' and you'll find this issue is not unique to me. follow those threads and many people are having a tough time finding solutions. Hopefully some will come across this thread.
I'd spent 6-8 hours looking for a solution and you've given me two.
i really appreciate your help.
thank you.
  • Like
Reactions: cPanelMichael