Count your Inodes/Files on your Cpanel Using PHP code

Home / Others / Count your Inodes/Files on your Cpanel Using PHP code

Are you struggling or looking for a inodes blasting issue on your server , I feel the same, After failed on many point.

An inode is a data structure used to keep information about a file on your hosting account. The number of inodes indicates the number of files and folders you have. This includes everything on your account, emails, files, folders, anything you store on the server.

You can check and count Files in your Directory and subdiectory wise via putting this code on a file in the parent directory which you need to analysis.

function GetFileCount($dir,$level,$minCountToDisplay){

if (is_dir($dir))
// this is a directory

// init file count value
$fileCount = 0;
if ($dh = opendir($dir))
// iterate through files in this directory
while (($file = readdir($dh)) !== false)
// skip moving up the directory tree, only go down!
if($file != ‘..’ && $file != ‘.’){
// recursive file counting
// clean up
} else {
// something went wrong, move on
echo(“Failed opening directory: $dir\n”);
// only print the file count if it meets our minimum value
if($fileCount >= $minCountToDisplay){
// str_pad for a clean layout
echo “<br/><br/>”;
return $fileCount+1;

} else {
// not a directory
return 1;

// default threshold to display a directory’s file count
$minCountToDisplay = 0;

// get command line params if any
// ie: php getfilecounts.php
// or: php getfilecounts.php min=500

parse_str(implode(‘&’, array_slice($argv, 1)), $a);
if(isset($a[‘min’]) && is_numeric($a[‘min’]) && $a[‘min’] > 1000){
$minCountToDisplay = $a[‘min’];

// set working directory to the one this file is in.
chdir ( dirname(__FILE__) );
echo “Current working directory: “;
echo getcwd().”\n<br/>”;

// display file counts

It will return with the file count with its directory Path.