Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Delete All Files & Folders | Recursive Functions (FREE, Python & PHP)

Delete All Files & Folders

So, you want to bulk delete files & folders on your server or computer right? Easy as pie! In this tutorial you will learn a bit more about PHP and Python. You can use either or for this, and there are also many other ways you could do this (C++, C#, C, Bash, Powershell, etc, etc). I chose PHP and Python because so much of the web is ran by PHP and I know many people use shared hosting which enables this by default. For Python, I chose it because it is a fast scripting language and is commonly used to perform bulk functions like recursive delete, read, analyze, etc.

This is a great way to clear out files and folders on your server, but keep in mind that it won't be able to remove files if it is not run with the right permissions, if there is a protection on the target folder/file, etc. Please be careful: you may not be able to recover deleted files! In the code I am using the path "./rm" so that you are forced to test it with a folder /rm/ first, or change the code yourself. Use at your own risk!




Python - Recursive Deletion - Source Code
Tested as of 1/7/2024 with Python 3.12

Spoiler (Click to View)




PHP - Recursive Deletion - Source Code
Tested as of 1/7/2024 with PHP 7.4x.
I don't use PHP much and don't have 8 installed on this specific laptop, but it should be fine for PHP 8x too.


Spoiler (Click to View)




I hope this has helped you! Now you can save these and use them as-needed for bulk deletions.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by DhorotyJan 26, 2020 03:35 AM 2 196 Jan 26, 2020 03:35 AM
Last Post: Dhoroty
by InjectorBoyJun 6, 2019 04:29 PM 14 1,385 Jun 6, 2019 04:29 PM
Last Post: demontronpc
by ♦ [̲̅$̲̅(̲̅1000)̲̅$̲̅] ♦Apr 11, 2014 11:05 AM 22 670 Apr 11, 2014 11:05 AM
Last Post: Yrame