Recursively Delete Matching Files via PHP -
i reworked naming convention of images on our website. when uploaded images altered names, ended getting images duplicated, 1 copy old naming convention , 1 new naming convention. images numbered in thousands , didn't want manually delete them all. so decided needed figure out php script capable of deleting old images site. luckily old images consistently named either ending of f.jpg or s.jpg. had find files endings , delete them. thought straightforward thing, whatever reason several different solutions found listed online didn't work right. ended going old code had posted on stackoverflow different purpose , reworked this. i'm posting code answer problem in case might useful else. below solution finding files matching naming convention in selected folder , sub-folders , deleting them. make work situation. you'll want place above directory want delete, , you'll specify specific folder replacing part have ./media/catalog/ . you'll want replace cr...