Bake vertex color to texture with python

Hello, I’m trying a find a way to bake existent vertex color/UV of an object to texture file with python code.

can anyone help me? I’m not really good at blender nor python :confused:

I found this:

Ob = context.active_object
UVLayer ='MathTextureUV') if 'MathTextureUV' not in else['MathTextureUV'] = UVLayer.active_render = True
Image ='MathTextureImage', self.texture_size, self.texture_size)
for uv in
     uv.image = Image
VLayer ='MathTextureVColor') if 'MathTextureVColor' not in else['MathTextureVColor'] = VLayer.active_render = True
#boring stuff
context.scene.render.bake_type = 'VERTEX_COLORS'

here: Baking textures with python

but this not exactly what I need because I already have UV and vertex color in my model — I just need to select objects and get textures in the given folder