PHP to extract and delete compressed files (rar/zip)
by z3n on Mar.11, 2009, under Coding
Problem:
After downloading massive stuff on the internet you need to do the boring process of extracting then deleting the compressed files from multiple folders etc etc
Solution:
A php script that extract all rar/zip files into all subfolders from the root folder you specify.
How to use:
on prompt:
php x.php /path/to/folder
if you are on windows it’s recommended that you put x.php on a folder before the ones you want to process, or at least into the same drive letter.
Note: Must have php_zip and php_rar libraries enabled on your php.ini
Note2: Apparetly there’s a bug on the php_rar library, even if i close the handler or even unset the object, the last file of a rar archive keeps being used, meaning that script can’t delete it, so you need to do it manually (you will need to wait the script finish uncompressing of all the subfolders before deleting).