note 64208 deleted from function.disk-total-space by nlopess

From: Date: Mon, 10 Apr 2006 17:07:05 +0000
Subject: note 64208 deleted from function.disk-total-space by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107713@lists.php.net to get a copy of this message
Note Submitter: php-net at kdcinfo dot com ---- My first contribution also, but alas, its only an enhancement (prior post tweak). I didn't just want the grand total of the directories and subdirectories scanned, as "shalless at rubix dot net dot au" graciously listed, but the total for each directory. I can then take that list into my spreadsheet app, and sort it based on size and find out which directories are eating up the most space (or those that are empty). I put the tilde ( ~ ) in there for easier porting into my spreadsheet app, using it as a delimiter. In addition, I store this utility in a directory one level down from my root, so using the "../" does my entire root. <? echo "<br><br>".dskspace("../"); function dskspace($dir) { $s = stat($dir); $space = $s["blocks"]*512; if (is_dir($dir)) { $dh = opendir($dir); while (($file = readdir($dh)) !== false) if ($file != "." and $file != "..") $space += dskspace($dir."/".$file); echo "<br>".round(($space/1024)/1024,2)." Mb ~ <strong>".$dir.$file."</strong>"; closedir($dh); } return $space; } ?> Never thought I'd know enough to post here :) http://kdcinfo.com/kdc_projects.shtml

« previous php.notes (#107713) next »