Manipulating PBR textures using python script

My motive is to try different PBR textures for a selected. I have, until now only being using PBR textures manually, I click on Principled BSDF node, press on Ctrl+Shift+T and then select appropriate PBR textures. I want to make this process automated. Here’s what I tried and it failed: I am running this after already setting up PBR material in material named bm.004. Blender version is 2.93
import bpy
bpy.ops.mesh.primitive_cube_add(size=4, location=(0,0,2))
cube = bpy.context.active_object
base_material =[‘bm.004’]
all_nodes = base_material.node_tree.nodes
base_color = all_nodes[‘Base Color’]
base_img = = ‘path of image file’)
base_color.image = base_img
The error I get is:
AttributeError: ‘NoneType’ object has no attribute ‘image’
Incase, I need to change the approach itself, please let me know.

Issue fixed!
I was earlier using wrong naming for Base Color Node. From 5th line of above code, it should be replaced by:
principled_bsdf = all_nodes.get(‘Principled BSDF’)
base_color = principled_bsdf.inputs[0].links[0].from_node
base_img = = ‘path of the file’)
base_color.image = base_img