Hello Cyberworld,
The code from your initial post works fine in Metashape 1.7.4 (just copied it to Metashape Console pane for some random project).
photo is just an intermediate variable name in the provided script and can be replaced by any other label in all the occurrences, it wouldn't affect the script.
So, if you have some problems with the script, please provide some additional details - are there any error messages, for example.