There are free scripts for IP to country conversion. Problem is the database. IP usage does change so to keep up to date you need to pay. I've seen free database sources, but they don't update as often.
You're welcome. You were probably looking for a direct link to scripts, but there are many options so it's better if you check the various ones out there to find the one you want.