How do i write a script that modify every material in the scene by creating and connecting a "UV map" node to every texture file node?
This script will iterate over all the materials in your scene, and add a texture mapping node to each material that has an image texture node. The mapping node's UV output applies the default UV map of the object using the material, so it should achieve the same result as using a UV texture node (that uses the default UV map). The script will then connect the mapping node's UV output to the image texture's input and that should do the trick.

Disclaimer: This script assumes you are using Cycles and will probably only work in with Cycles materials.

import bpy

M = bpy.data.materials

for m in M:
    t = m.node_tree

    # Get all image texture nodes in each material's node tree's
    img_textures = [ n for n in t.nodes if n.type == 'TEX_IMAGE' ]
    if len( img_textures ): # If material has at least 1 image texture
        imgTex = img_textures[0] # Get the first (and probably only) image texture node in list

        # Create a new Mapping node (its UV output uses the default UV map so it's simpler than the UV map node)
        texMap = t.nodes.new('ShaderNodeTexCoord')

        # Link the texture mapping node to the image texture node
        t.links.new( imgTex.inputs[0], texMap.outputs['UV'] )