Here is one way to remove empty categories ...
$categoryCollection = Mage::getModel('catalog/category')->getCollection() ->addFieldToFilter('level', array('gteq' => 2)) ; foreach($categoryCollection as $category) { if ($category->getProductCount() === 0) { $category->delete(); } }
This will delete the categories - don't just hide them
EDIT
To respond to the following comment, follow these steps:
"Could you please share a link of some tutorial or weblink.I am weak in creating custom modules".
see here
It is best to create a script for this simple task. Here is a good resource to explain how to run Magento to run your script.
source share