Script to select all vertices in an object and assign new vertex group
The code below is loops trough every selected object:


delete all vertex groups
create a new vertex group named as the object itself
then assigns every vertices in the object to the group


So all you need to do is, select your objects then Run Script.

import bpy
import sys
import logging
# config for logging
logging.basicConfig(level=logging.DEBUG)

def createVertexGroupForObject(aObject):
    # set to object mide : "VertexGroup.add(): cannot be called while object is in edit mode"
    bpy.ops.object.mode_set(mode='OBJECT')    

    # remove all vertex groups
    for vertexGroup in aObject.vertex_groups:
        aObject.vertex_groups.remove(vertexGroup)

    # add new vertex group with the name of object        
    newGroup = aObject.vertex_groups.new(aObject.name)

    # assign objects vertices to vertex group
    verticesToAdd = []
    for vertex in aObject.data.vertices:
        verticesToAdd.append(vertex.index)

    try:
        newGroup.add(verticesToAdd, 1.0, "ADD")
        logging.debug("\t\tvertex group added")
    except:
        logging.error(sys.exc_info())

# get selected objects
selected = bpy.context.selected_objects

for obj in selected:
    logging.debug("\tselected: " + obj.name)

    createVertexGroupForObject(obj)