If you are creating a product import script for Magento, you probably need to generate on the fly all your category ids based on category names. Here is a situation where you can use this script.